@aeternity/aepp-sdk 8.2.0 → 10.0.0-beta.1
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 +16 -9
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -9
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +1 -1
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +1 -1
- package/dist/aepp-sdk.js.map +1 -1
- package/es/account/base.js +33 -119
- package/es/account/base.js.map +1 -1
- package/es/account/memory.js +17 -19
- package/es/account/memory.js.map +1 -1
- package/es/account/multiple.js +75 -154
- package/es/account/multiple.js.map +1 -1
- package/es/ae/aens.js +164 -599
- package/es/ae/aens.js.map +1 -1
- package/es/ae/contract.js +108 -916
- package/es/ae/contract.js.map +1 -1
- package/es/ae/index.js +89 -250
- package/es/ae/index.js.map +1 -1
- package/es/ae/oracle.js +132 -500
- package/es/ae/oracle.js.map +1 -1
- package/es/chain/index.js +4 -23
- package/es/chain/index.js.map +1 -1
- package/es/chain/node.js +292 -1018
- package/es/chain/node.js.map +1 -1
- package/es/channel/handlers.js +597 -1086
- package/es/channel/handlers.js.map +1 -1
- package/es/channel/index.js +203 -451
- package/es/channel/index.js.map +1 -1
- package/es/channel/internal.js +129 -301
- package/es/channel/internal.js.map +1 -1
- package/es/contract/aci/index.js +319 -491
- package/es/contract/aci/index.js.map +1 -1
- package/es/contract/aci/transformation.js +35 -711
- package/es/contract/aci/transformation.js.map +1 -1
- package/es/contract/compiler.js +129 -203
- package/es/contract/compiler.js.map +1 -1
- package/es/contract/ga/helpers.js +17 -122
- package/es/contract/ga/helpers.js.map +1 -1
- package/es/contract/ga/index.js +102 -247
- package/es/contract/ga/index.js.map +1 -1
- package/es/contract/index.js +1 -1
- package/es/contract/index.js.map +1 -1
- package/es/index.js +2 -3
- package/es/index.js.map +1 -1
- package/es/node-pool/index.js +54 -73
- package/es/node-pool/index.js.map +1 -1
- package/es/node.js +56 -157
- package/es/node.js.map +1 -1
- package/es/other.d.ts +1 -1
- package/es/tx/builder/helpers.js +49 -89
- package/es/tx/builder/helpers.js.map +1 -1
- package/es/tx/builder/index.js +205 -303
- package/es/tx/builder/index.js.map +1 -1
- package/es/tx/builder/schema.js +585 -573
- package/es/tx/builder/schema.js.map +1 -1
- package/es/tx/index.js +1 -1
- package/es/tx/index.js.map +1 -1
- package/es/tx/tx-object.js +105 -135
- package/es/tx/tx-object.js.map +1 -1
- package/es/tx/tx.js +810 -1586
- package/es/tx/tx.js.map +1 -1
- package/es/tx/validator.js +191 -426
- package/es/tx/validator.js.map +1 -1
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +17 -21
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +1 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +38 -74
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +1 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.js +14 -15
- package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +1 -1
- package/es/utils/aepp-wallet-communication/helpers.js +60 -105
- package/es/utils/aepp-wallet-communication/helpers.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +179 -510
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +70 -89
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +354 -603
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +1 -1
- package/es/utils/aepp-wallet-communication/schema.js +43 -39
- package/es/utils/aepp-wallet-communication/schema.js.map +1 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.js +32 -58
- package/es/utils/aepp-wallet-communication/wallet-detector.js.map +1 -1
- package/es/utils/amount-formatter.js +41 -61
- package/es/utils/amount-formatter.js.map +1 -1
- package/es/utils/async-init.js +28 -64
- package/es/utils/async-init.js.map +1 -1
- package/es/utils/bignumber.js +3 -11
- package/es/utils/bignumber.js.map +1 -1
- package/es/utils/bytes.js +5 -9
- package/es/utils/bytes.js.map +1 -1
- package/es/utils/crypto.js +49 -75
- package/es/utils/crypto.js.map +1 -1
- package/es/utils/hd-wallet.js +45 -81
- package/es/utils/hd-wallet.js.map +1 -1
- package/es/utils/json-big.js +16 -49
- package/es/utils/json-big.js.map +1 -1
- package/es/utils/keystore.js +81 -246
- package/es/utils/keystore.js.map +1 -1
- package/es/utils/mptree.js +88 -134
- package/es/utils/mptree.js.map +1 -1
- package/es/utils/other.js +10 -60
- package/es/utils/other.js.map +1 -1
- package/es/utils/semver-satisfies.js +9 -28
- package/es/utils/semver-satisfies.js.map +1 -1
- package/es/utils/string.js +4 -13
- package/es/utils/string.js.map +1 -1
- package/es/utils/swagger.js +85 -218
- package/es/utils/swagger.js.map +1 -1
- package/package.json +52 -43
- package/src/account/base.js +8 -9
- package/src/account/multiple.js +20 -16
- package/src/ae/aens.js +25 -21
- package/src/ae/contract.js +65 -246
- package/src/ae/index.js +31 -7
- package/src/ae/oracle.js +21 -17
- package/src/chain/index.js +2 -12
- package/src/chain/node.js +26 -29
- package/src/channel/handlers.js +0 -1
- package/src/channel/index.js +4 -5
- package/src/contract/aci/index.js +221 -106
- package/src/contract/aci/transformation.js +30 -422
- package/src/contract/compiler.js +45 -4
- package/src/contract/ga/helpers.js +2 -12
- package/src/contract/ga/index.js +22 -26
- package/src/index.js +2 -4
- package/src/node-pool/index.js +21 -12
- package/src/node.js +22 -26
- package/src/tx/builder/helpers.js +12 -24
- package/src/tx/builder/index.js +18 -15
- package/src/tx/builder/schema.js +43 -108
- package/src/tx/tx-object.js +0 -2
- package/src/tx/tx.js +157 -144
- package/src/tx/validator.js +134 -202
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +1 -3
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +9 -10
- package/src/utils/aepp-wallet-communication/schema.js +1 -3
- package/src/utils/amount-formatter.ts +1 -1
- package/src/utils/bignumber.ts +2 -1
- package/src/utils/crypto.js +4 -17
- package/src/utils/other.ts +1 -1
- package/src/utils/semver-satisfies.ts +1 -1
- package/src/utils/swagger.js +24 -7
- package/CHANGELOG.md +0 -1716
- package/src/contract/aci/helpers.js +0 -140
|
@@ -1,130 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
-
|
|
10
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context13; _forEachInstanceProperty(_context13 = ownKeys(Object(source), true)).call(_context13, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context14; _forEachInstanceProperty(_context14 = ownKeys(Object(source))).call(_context14, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
11
|
-
|
|
12
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
13
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
14
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
15
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
16
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
17
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
18
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
19
|
-
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
|
20
|
-
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
|
21
|
-
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
1
|
+
/**
|
|
2
|
+
* RPC handler for AEPP side
|
|
3
|
+
*
|
|
4
|
+
* @module @aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc
|
|
5
|
+
* @export AeppRpc
|
|
6
|
+
* @example import ContentScriptBridge from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc'
|
|
7
|
+
*/
|
|
22
8
|
import { v4 as uuid } from 'uuid';
|
|
23
9
|
import Ae from '../../../ae';
|
|
24
10
|
import RpcClient from './rpc-client';
|
|
25
11
|
import { getHandler, message, voidFn } from '../helpers';
|
|
26
12
|
import { METHODS, RPC_STATUS, VERSION } from '../schema';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
const NOTIFICATIONS = {
|
|
14
|
+
[METHODS.wallet.updateAddress]: instance => _ref => {
|
|
15
|
+
let {
|
|
16
|
+
params
|
|
17
|
+
} = _ref;
|
|
30
18
|
instance.rpcClient.accounts = params;
|
|
31
19
|
instance.onAddressChange(params);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return function (msg) {
|
|
20
|
+
},
|
|
21
|
+
[METHODS.updateNetwork]: instance => msg => {
|
|
35
22
|
instance.rpcClient.info.networkId = msg.params.networkId;
|
|
36
23
|
instance.onNetworkChange(msg.params);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return function (msg) {
|
|
24
|
+
},
|
|
25
|
+
[METHODS.closeConnection]: instance => msg => {
|
|
40
26
|
instance.disconnectWallet();
|
|
41
27
|
instance.onDisconnect(msg.params);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
}), _defineProperty(_RESPONSES, METHODS.aepp.connect, function (instance) {
|
|
49
|
-
return function (msg) {
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const RESPONSES = {
|
|
31
|
+
[METHODS.aepp.address]: instance => msg => instance.rpcClient.processResponse(msg),
|
|
32
|
+
[METHODS.aepp.connect]: instance => msg => {
|
|
50
33
|
if (msg.result) instance.rpcClient.info.status = RPC_STATUS.CONNECTED;
|
|
51
34
|
instance.rpcClient.processResponse(msg);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return function (msg) {
|
|
35
|
+
},
|
|
36
|
+
[METHODS.aepp.subscribeAddress]: instance => msg => {
|
|
55
37
|
if (msg.result) {
|
|
56
38
|
msg.result.address && (instance.rpcClient.accounts = msg.result.address);
|
|
57
39
|
msg.result.subscription && (instance.rpcClient.addressSubscription = msg.result.subscription);
|
|
58
40
|
}
|
|
59
41
|
|
|
60
|
-
instance.rpcClient.processResponse(msg,
|
|
61
|
-
|
|
62
|
-
|
|
42
|
+
instance.rpcClient.processResponse(msg, _ref2 => {
|
|
43
|
+
let {
|
|
44
|
+
id,
|
|
45
|
+
result
|
|
46
|
+
} = _ref2;
|
|
63
47
|
return [result];
|
|
64
48
|
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
49
|
+
},
|
|
50
|
+
[METHODS.aepp.sign]: instance => msg => {
|
|
51
|
+
instance.rpcClient.processResponse(msg, _ref3 => {
|
|
52
|
+
let {
|
|
53
|
+
id,
|
|
54
|
+
result
|
|
55
|
+
} = _ref3;
|
|
71
56
|
return [result.signedTransaction || result.transactionHash];
|
|
72
57
|
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
58
|
+
},
|
|
59
|
+
[METHODS.aepp.signMessage]: instance => msg => {
|
|
60
|
+
instance.rpcClient.processResponse(msg, _ref4 => {
|
|
61
|
+
let {
|
|
62
|
+
id,
|
|
63
|
+
result
|
|
64
|
+
} = _ref4;
|
|
79
65
|
return [result.signature];
|
|
80
66
|
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})(instance)(msg));
|
|
100
|
-
|
|
101
|
-
case 4:
|
|
102
|
-
if (!Object.prototype.hasOwnProperty.call(instance.rpcClient.callbacks, msg.id)) {
|
|
103
|
-
_context.next = 8;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return _context.abrupt("return", getHandler(RESPONSES, msg, {
|
|
108
|
-
debug: instance.debug
|
|
109
|
-
})(instance)(msg));
|
|
110
|
-
|
|
111
|
-
case 8:
|
|
112
|
-
return _context.abrupt("return", getHandler(REQUESTS, msg, {
|
|
113
|
-
debug: instance.debug
|
|
114
|
-
})(instance)(msg));
|
|
115
|
-
|
|
116
|
-
case 9:
|
|
117
|
-
case "end":
|
|
118
|
-
return _context.stop();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}, _callee);
|
|
122
|
-
}));
|
|
123
|
-
|
|
124
|
-
return function (_x) {
|
|
125
|
-
return _ref5.apply(this, arguments);
|
|
126
|
-
};
|
|
127
|
-
}();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const REQUESTS = {};
|
|
70
|
+
|
|
71
|
+
const handleMessage = instance => async msg => {
|
|
72
|
+
if (!msg.id) {
|
|
73
|
+
return getHandler(NOTIFICATIONS, msg, {
|
|
74
|
+
debug: instance.debug
|
|
75
|
+
})(instance)(msg);
|
|
76
|
+
} else if (Object.prototype.hasOwnProperty.call(instance.rpcClient.callbacks, msg.id)) {
|
|
77
|
+
return getHandler(RESPONSES, msg, {
|
|
78
|
+
debug: instance.debug
|
|
79
|
+
})(instance)(msg);
|
|
80
|
+
} else {
|
|
81
|
+
return getHandler(REQUESTS, msg, {
|
|
82
|
+
debug: instance.debug
|
|
83
|
+
})(instance)(msg);
|
|
84
|
+
}
|
|
128
85
|
};
|
|
129
86
|
/**
|
|
130
87
|
* Contain functionality for wallet interaction and connect it to sdk
|
|
@@ -142,48 +99,36 @@ var handleMessage = function handleMessage(instance) {
|
|
|
142
99
|
|
|
143
100
|
|
|
144
101
|
export default Ae.compose({
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
_this.onNetworkChange = onNetworkChange; // validation
|
|
174
|
-
|
|
175
|
-
_forEachInstanceProperty(eventsHandlers).call(eventsHandlers, function (event) {
|
|
176
|
-
if (!forceValidation && typeof _this[event] !== 'function') throw new Error("Call-back for ".concat(event, " must be an function!"));
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
case 12:
|
|
180
|
-
case "end":
|
|
181
|
-
return _context2.stop();
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}, _callee2);
|
|
185
|
-
}))();
|
|
102
|
+
async init(_ref5) {
|
|
103
|
+
let {
|
|
104
|
+
name,
|
|
105
|
+
onAddressChange = voidFn,
|
|
106
|
+
onDisconnect = voidFn,
|
|
107
|
+
onNetworkChange = voidFn,
|
|
108
|
+
connection,
|
|
109
|
+
forceValidation = false,
|
|
110
|
+
debug = false
|
|
111
|
+
} = _ref5;
|
|
112
|
+
const eventsHandlers = ['onDisconnect', 'onAddressChange', 'onNetworkChange'];
|
|
113
|
+
this.connection = connection;
|
|
114
|
+
this.name = name;
|
|
115
|
+
this.debug = debug;
|
|
116
|
+
|
|
117
|
+
if (connection) {
|
|
118
|
+
// Init RPCClient
|
|
119
|
+
await this.connectToWallet(connection);
|
|
120
|
+
} // Event callbacks
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
this.onDisconnect = onDisconnect;
|
|
124
|
+
this.onAddressChange = onAddressChange;
|
|
125
|
+
this.onNetworkChange = onNetworkChange; // validation
|
|
126
|
+
|
|
127
|
+
eventsHandlers.forEach(event => {
|
|
128
|
+
if (!forceValidation && typeof this[event] !== 'function') throw new Error(`Call-back for ${event} must be an function!`);
|
|
129
|
+
});
|
|
186
130
|
},
|
|
131
|
+
|
|
187
132
|
deepProps: {
|
|
188
133
|
Ae: {
|
|
189
134
|
defaults: {
|
|
@@ -192,12 +137,11 @@ export default Ae.compose({
|
|
|
192
137
|
}
|
|
193
138
|
},
|
|
194
139
|
methods: {
|
|
195
|
-
sign
|
|
196
|
-
addresses: function addresses() {
|
|
197
|
-
var _context3;
|
|
140
|
+
sign() {},
|
|
198
141
|
|
|
142
|
+
addresses() {
|
|
199
143
|
if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.');
|
|
200
|
-
return
|
|
144
|
+
return [this.rpcClient.currentAccount, ...Object.keys(this.rpcClient.accounts.connected)];
|
|
201
145
|
},
|
|
202
146
|
|
|
203
147
|
/**
|
|
@@ -208,40 +152,18 @@ export default Ae.compose({
|
|
|
208
152
|
* @param {Object} connection Wallet connection object
|
|
209
153
|
* @return {void}
|
|
210
154
|
*/
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
throw new Error('You are already connected to wallet ' + _this2.rpcClient);
|
|
225
|
-
|
|
226
|
-
case 2:
|
|
227
|
-
_this2.rpcClient = RpcClient(_objectSpread(_objectSpread({
|
|
228
|
-
connection: connection,
|
|
229
|
-
networkId: _this2.getNetworkId({
|
|
230
|
-
force: true
|
|
231
|
-
})
|
|
232
|
-
}, connection.connectionInfo), {}, {
|
|
233
|
-
id: uuid(),
|
|
234
|
-
handlers: [handleMessage(_this2), _this2.onDisconnect]
|
|
235
|
-
}));
|
|
236
|
-
return _context4.abrupt("return", _this2.sendConnectRequest());
|
|
237
|
-
|
|
238
|
-
case 4:
|
|
239
|
-
case "end":
|
|
240
|
-
return _context4.stop();
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}, _callee3);
|
|
244
|
-
}))();
|
|
155
|
+
async connectToWallet(connection) {
|
|
156
|
+
if (this.rpcClient && this.rpcClient.isConnected()) throw new Error('You are already connected to wallet ' + this.rpcClient);
|
|
157
|
+
this.rpcClient = RpcClient({
|
|
158
|
+
connection,
|
|
159
|
+
networkId: this.getNetworkId({
|
|
160
|
+
force: true
|
|
161
|
+
}),
|
|
162
|
+
...connection.connectionInfo,
|
|
163
|
+
id: uuid(),
|
|
164
|
+
handlers: [handleMessage(this), this.onDisconnect]
|
|
165
|
+
});
|
|
166
|
+
return this.sendConnectRequest();
|
|
245
167
|
},
|
|
246
168
|
|
|
247
169
|
/**
|
|
@@ -252,90 +174,25 @@ export default Ae.compose({
|
|
|
252
174
|
* @param {Boolean} sendDisconnect=false Force sending close connection message
|
|
253
175
|
* @return {void}
|
|
254
176
|
*/
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
switch (_context5.prev = _context5.next) {
|
|
264
|
-
case 0:
|
|
265
|
-
sendDisconnect = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : true;
|
|
266
|
-
|
|
267
|
-
if (!(!_this3.rpcClient || !_this3.rpcClient.isConnected())) {
|
|
268
|
-
_context5.next = 3;
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
throw new Error('You are not connected to Wallet');
|
|
273
|
-
|
|
274
|
-
case 3:
|
|
275
|
-
sendDisconnect && _this3.rpcClient.sendMessage(message(METHODS.closeConnection, {
|
|
276
|
-
reason: 'bye'
|
|
277
|
-
}), true);
|
|
278
|
-
|
|
279
|
-
_this3.rpcClient.disconnect();
|
|
280
|
-
|
|
281
|
-
_this3.rpcClient = null;
|
|
282
|
-
|
|
283
|
-
case 6:
|
|
284
|
-
case "end":
|
|
285
|
-
return _context5.stop();
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}, _callee4);
|
|
289
|
-
}))();
|
|
177
|
+
async disconnectWallet() {
|
|
178
|
+
let sendDisconnect = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
179
|
+
if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet');
|
|
180
|
+
sendDisconnect && this.rpcClient.sendMessage(message(METHODS.closeConnection, {
|
|
181
|
+
reason: 'bye'
|
|
182
|
+
}), true);
|
|
183
|
+
this.rpcClient.disconnect();
|
|
184
|
+
this.rpcClient = null;
|
|
290
185
|
},
|
|
291
|
-
address: function address() {
|
|
292
|
-
var _arguments2 = arguments,
|
|
293
|
-
_this4 = this;
|
|
294
|
-
|
|
295
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
296
|
-
var _ref7, onAccount, current;
|
|
297
|
-
|
|
298
|
-
return _regeneratorRuntime.wrap(function _callee5$(_context6) {
|
|
299
|
-
while (1) {
|
|
300
|
-
switch (_context6.prev = _context6.next) {
|
|
301
|
-
case 0:
|
|
302
|
-
_ref7 = _arguments2.length > 0 && _arguments2[0] !== undefined ? _arguments2[0] : {}, onAccount = _ref7.onAccount;
|
|
303
|
-
|
|
304
|
-
if (!(!_this4.rpcClient || !_this4.rpcClient.isConnected())) {
|
|
305
|
-
_context6.next = 3;
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
throw new Error('You are not connected to Wallet');
|
|
310
|
-
|
|
311
|
-
case 3:
|
|
312
|
-
current = _this4.rpcClient.currentAccount;
|
|
313
|
-
|
|
314
|
-
if (current) {
|
|
315
|
-
_context6.next = 6;
|
|
316
|
-
break;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
throw new Error('You are not subscribed for an account.');
|
|
320
|
-
|
|
321
|
-
case 6:
|
|
322
|
-
if (!(onAccount && !_this4.rpcClient.hasAccessToAccount(onAccount))) {
|
|
323
|
-
_context6.next = 8;
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
186
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
}, _callee5);
|
|
338
|
-
}))();
|
|
187
|
+
async address() {
|
|
188
|
+
let {
|
|
189
|
+
onAccount
|
|
190
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
191
|
+
if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet');
|
|
192
|
+
const current = this.rpcClient.currentAccount;
|
|
193
|
+
if (!current) throw new Error('You are not subscribed for an account.');
|
|
194
|
+
if (onAccount && !this.rpcClient.hasAccessToAccount(onAccount)) throw new Error(`You do not have access to account ${onAccount}`);
|
|
195
|
+
return onAccount || current;
|
|
339
196
|
},
|
|
340
197
|
|
|
341
198
|
/**
|
|
@@ -345,39 +202,10 @@ export default Ae.compose({
|
|
|
345
202
|
* @rtype () => Promise
|
|
346
203
|
* @return {Promise} Address from wallet
|
|
347
204
|
*/
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
return
|
|
352
|
-
return _regeneratorRuntime.wrap(function _callee6$(_context7) {
|
|
353
|
-
while (1) {
|
|
354
|
-
switch (_context7.prev = _context7.next) {
|
|
355
|
-
case 0:
|
|
356
|
-
if (!(!_this5.rpcClient || !_this5.rpcClient.isConnected())) {
|
|
357
|
-
_context7.next = 2;
|
|
358
|
-
break;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
throw new Error('You are not connected to Wallet');
|
|
362
|
-
|
|
363
|
-
case 2:
|
|
364
|
-
if (_this5.rpcClient.currentAccount) {
|
|
365
|
-
_context7.next = 4;
|
|
366
|
-
break;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
throw new Error('You are not subscribed for an account.');
|
|
370
|
-
|
|
371
|
-
case 4:
|
|
372
|
-
return _context7.abrupt("return", _this5.rpcClient.request(METHODS.aepp.address));
|
|
373
|
-
|
|
374
|
-
case 5:
|
|
375
|
-
case "end":
|
|
376
|
-
return _context7.stop();
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}, _callee6);
|
|
380
|
-
}))();
|
|
205
|
+
async askAddresses() {
|
|
206
|
+
if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet');
|
|
207
|
+
if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.');
|
|
208
|
+
return this.rpcClient.request(METHODS.aepp.address);
|
|
381
209
|
},
|
|
382
210
|
|
|
383
211
|
/**
|
|
@@ -389,34 +217,12 @@ export default Ae.compose({
|
|
|
389
217
|
* @param {String} value Subscription action('subscribe'|'unsubscribe')
|
|
390
218
|
* @return {Promise} Address from wallet
|
|
391
219
|
*/
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
switch (_context8.prev = _context8.next) {
|
|
399
|
-
case 0:
|
|
400
|
-
if (!(!_this6.rpcClient || !_this6.rpcClient.isConnected())) {
|
|
401
|
-
_context8.next = 2;
|
|
402
|
-
break;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
throw new Error('You are not connected to Wallet');
|
|
406
|
-
|
|
407
|
-
case 2:
|
|
408
|
-
return _context8.abrupt("return", _this6.rpcClient.request(METHODS.aepp.subscribeAddress, {
|
|
409
|
-
type: type,
|
|
410
|
-
value: value
|
|
411
|
-
}));
|
|
412
|
-
|
|
413
|
-
case 3:
|
|
414
|
-
case "end":
|
|
415
|
-
return _context8.stop();
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}, _callee7);
|
|
419
|
-
}))();
|
|
220
|
+
async subscribeAddress(type, value) {
|
|
221
|
+
if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet');
|
|
222
|
+
return this.rpcClient.request(METHODS.aepp.subscribeAddress, {
|
|
223
|
+
type,
|
|
224
|
+
value
|
|
225
|
+
});
|
|
420
226
|
},
|
|
421
227
|
|
|
422
228
|
/**
|
|
@@ -427,55 +233,16 @@ export default Ae.compose({
|
|
|
427
233
|
* @rtype (tx: String, options = {}) => Promise
|
|
428
234
|
* @return {Promise<String>} Signed transaction
|
|
429
235
|
*/
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
opt = _arguments3.length > 1 && _arguments3[1] !== undefined ? _arguments3[1] : {};
|
|
441
|
-
|
|
442
|
-
if (!(!_this7.rpcClient || !_this7.rpcClient.isConnected())) {
|
|
443
|
-
_context9.next = 3;
|
|
444
|
-
break;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
throw new Error('You are not connected to Wallet');
|
|
448
|
-
|
|
449
|
-
case 3:
|
|
450
|
-
if (_this7.rpcClient.currentAccount) {
|
|
451
|
-
_context9.next = 5;
|
|
452
|
-
break;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
throw new Error('You are not subscribed for an account.');
|
|
456
|
-
|
|
457
|
-
case 5:
|
|
458
|
-
if (!(opt.onAccount && !_this7.rpcClient.hasAccessToAccount(opt.onAccount))) {
|
|
459
|
-
_context9.next = 7;
|
|
460
|
-
break;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
throw new Error("You do not have access to account ".concat(opt.onAccount));
|
|
464
|
-
|
|
465
|
-
case 7:
|
|
466
|
-
return _context9.abrupt("return", _this7.rpcClient.request(METHODS.aepp.sign, _objectSpread(_objectSpread({}, opt), {}, {
|
|
467
|
-
tx: tx,
|
|
468
|
-
returnSigned: true,
|
|
469
|
-
networkId: _this7.getNetworkId()
|
|
470
|
-
})));
|
|
471
|
-
|
|
472
|
-
case 8:
|
|
473
|
-
case "end":
|
|
474
|
-
return _context9.stop();
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}, _callee8);
|
|
478
|
-
}))();
|
|
236
|
+
async signTransaction(tx) {
|
|
237
|
+
let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
238
|
+
if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet');
|
|
239
|
+
if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.');
|
|
240
|
+
if (opt.onAccount && !this.rpcClient.hasAccessToAccount(opt.onAccount)) throw new Error(`You do not have access to account ${opt.onAccount}`);
|
|
241
|
+
return this.rpcClient.request(METHODS.aepp.sign, { ...opt,
|
|
242
|
+
tx,
|
|
243
|
+
returnSigned: true,
|
|
244
|
+
networkId: this.getNetworkId()
|
|
245
|
+
});
|
|
479
246
|
},
|
|
480
247
|
|
|
481
248
|
/**
|
|
@@ -486,53 +253,14 @@ export default Ae.compose({
|
|
|
486
253
|
* @rtype (msg: String, options = {}) => Promise
|
|
487
254
|
* @return {Promise<String>} Signed transaction
|
|
488
255
|
*/
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
switch (_context10.prev = _context10.next) {
|
|
498
|
-
case 0:
|
|
499
|
-
opt = _arguments4.length > 1 && _arguments4[1] !== undefined ? _arguments4[1] : {};
|
|
500
|
-
|
|
501
|
-
if (!(!_this8.rpcClient || !_this8.rpcClient.isConnected())) {
|
|
502
|
-
_context10.next = 3;
|
|
503
|
-
break;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
throw new Error('You are not connected to Wallet');
|
|
507
|
-
|
|
508
|
-
case 3:
|
|
509
|
-
if (_this8.rpcClient.currentAccount) {
|
|
510
|
-
_context10.next = 5;
|
|
511
|
-
break;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
throw new Error('You are not subscribed for an account.');
|
|
515
|
-
|
|
516
|
-
case 5:
|
|
517
|
-
if (!(opt.onAccount && !_this8.rpcClient.hasAccessToAccount(opt.onAccount))) {
|
|
518
|
-
_context10.next = 7;
|
|
519
|
-
break;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
throw new Error("You do not have access to account ".concat(opt.onAccount));
|
|
523
|
-
|
|
524
|
-
case 7:
|
|
525
|
-
return _context10.abrupt("return", _this8.rpcClient.request(METHODS.aepp.signMessage, _objectSpread(_objectSpread({}, opt), {}, {
|
|
526
|
-
message: msg
|
|
527
|
-
})));
|
|
528
|
-
|
|
529
|
-
case 8:
|
|
530
|
-
case "end":
|
|
531
|
-
return _context10.stop();
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
}, _callee9);
|
|
535
|
-
}))();
|
|
256
|
+
async signMessage(msg) {
|
|
257
|
+
let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
258
|
+
if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet');
|
|
259
|
+
if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.');
|
|
260
|
+
if (opt.onAccount && !this.rpcClient.hasAccessToAccount(opt.onAccount)) throw new Error(`You do not have access to account ${opt.onAccount}`);
|
|
261
|
+
return this.rpcClient.request(METHODS.aepp.signMessage, { ...opt,
|
|
262
|
+
message: msg
|
|
263
|
+
});
|
|
536
264
|
},
|
|
537
265
|
|
|
538
266
|
/**
|
|
@@ -542,29 +270,14 @@ export default Ae.compose({
|
|
|
542
270
|
* @rtype () => Promise
|
|
543
271
|
* @return {Promise} Connection response
|
|
544
272
|
*/
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
return _context11.abrupt("return", _this9.rpcClient.request(METHODS.aepp.connect, {
|
|
554
|
-
name: _this9.name,
|
|
555
|
-
version: VERSION,
|
|
556
|
-
networkId: _this9.getNetworkId({
|
|
557
|
-
force: true
|
|
558
|
-
})
|
|
559
|
-
}));
|
|
560
|
-
|
|
561
|
-
case 1:
|
|
562
|
-
case "end":
|
|
563
|
-
return _context11.stop();
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
}, _callee10);
|
|
567
|
-
}))();
|
|
273
|
+
async sendConnectRequest() {
|
|
274
|
+
return this.rpcClient.request(METHODS.aepp.connect, {
|
|
275
|
+
name: this.name,
|
|
276
|
+
version: VERSION,
|
|
277
|
+
networkId: this.getNetworkId({
|
|
278
|
+
force: true
|
|
279
|
+
})
|
|
280
|
+
});
|
|
568
281
|
},
|
|
569
282
|
|
|
570
283
|
/**
|
|
@@ -579,74 +292,30 @@ export default Ae.compose({
|
|
|
579
292
|
* @param {Object} [options.walletBroadcast=true]
|
|
580
293
|
* @return {Promise<Object>} Transaction broadcast result
|
|
581
294
|
*/
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
throw new Error('You are not connected to Wallet');
|
|
600
|
-
|
|
601
|
-
case 3:
|
|
602
|
-
if (_this10.rpcClient.currentAccount) {
|
|
603
|
-
_context12.next = 5;
|
|
604
|
-
break;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
throw new Error('You are not subscribed for an account.');
|
|
608
|
-
|
|
609
|
-
case 5:
|
|
610
|
-
if (!(options.onAccount && !_this10.rpcClient.hasAccessToAccount(options.onAccount))) {
|
|
611
|
-
_context12.next = 7;
|
|
612
|
-
break;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
throw new Error("You do not have access to account ".concat(options.onAccount));
|
|
616
|
-
|
|
617
|
-
case 7:
|
|
618
|
-
opt = _merge(_this10.Ae.defaults, options);
|
|
619
|
-
|
|
620
|
-
if (opt.walletBroadcast) {
|
|
621
|
-
_context12.next = 13;
|
|
622
|
-
break;
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
_context12.next = 11;
|
|
626
|
-
return _this10.signTransaction(tx, {
|
|
627
|
-
onAccount: opt.onAccount
|
|
628
|
-
});
|
|
629
|
-
|
|
630
|
-
case 11:
|
|
631
|
-
signed = _context12.sent;
|
|
632
|
-
return _context12.abrupt("return", _this10.sendTransaction(signed, opt));
|
|
633
|
-
|
|
634
|
-
case 13:
|
|
635
|
-
return _context12.abrupt("return", _this10.rpcClient.request(METHODS.aepp.sign, {
|
|
636
|
-
onAccount: opt.onAccount,
|
|
637
|
-
tx: tx,
|
|
638
|
-
returnSigned: false,
|
|
639
|
-
networkId: _this10.getNetworkId()
|
|
640
|
-
}));
|
|
295
|
+
async send(tx) {
|
|
296
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
297
|
+
if (!this.rpcClient || !this.rpcClient.isConnected()) throw new Error('You are not connected to Wallet');
|
|
298
|
+
if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.');
|
|
299
|
+
if (options.onAccount && !this.rpcClient.hasAccessToAccount(options.onAccount)) throw new Error(`You do not have access to account ${options.onAccount}`);
|
|
300
|
+
const opt = { ...this.Ae.defaults,
|
|
301
|
+
...options
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
if (!opt.walletBroadcast) {
|
|
305
|
+
const signed = await this.signTransaction(tx, {
|
|
306
|
+
onAccount: opt.onAccount
|
|
307
|
+
});
|
|
308
|
+
return this.sendTransaction(signed, opt);
|
|
309
|
+
}
|
|
641
310
|
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
}))();
|
|
311
|
+
return this.rpcClient.request(METHODS.aepp.sign, {
|
|
312
|
+
onAccount: opt.onAccount,
|
|
313
|
+
tx,
|
|
314
|
+
returnSigned: false,
|
|
315
|
+
networkId: this.getNetworkId()
|
|
316
|
+
});
|
|
649
317
|
}
|
|
318
|
+
|
|
650
319
|
}
|
|
651
320
|
});
|
|
652
321
|
//# sourceMappingURL=aepp-rpc.js.map
|