@aeternity/aepp-sdk 12.0.0 → 12.1.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/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -15
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +2 -1
- package/dist/aepp-sdk.browser.js.LICENSE.txt +1 -0
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +20764 -1
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.d.ts +7 -7
- package/es/AeSdk.mjs.map +1 -1
- package/es/AeSdkAepp.d.ts +4 -3
- package/es/AeSdkAepp.mjs +2 -1
- package/es/AeSdkAepp.mjs.map +1 -1
- package/es/AeSdkBase.d.ts +22 -21
- package/es/AeSdkBase.mjs +25 -21
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkWallet.d.ts +4 -3
- package/es/AeSdkWallet.mjs +5 -1
- package/es/AeSdkWallet.mjs.map +1 -1
- package/es/Node.d.ts +7 -10
- package/es/Node.mjs +63 -57
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +7 -4
- package/es/account/Base.mjs +3 -3
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Memory.d.ts +5 -4
- package/es/account/Memory.mjs +24 -2
- package/es/account/Memory.mjs.map +1 -1
- package/es/account/Rpc.d.ts +6 -6
- package/es/account/Rpc.mjs +3 -2
- package/es/account/Rpc.mjs.map +1 -1
- package/es/aens.d.ts +27 -14
- package/es/aens.mjs +27 -21
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/Browser.d.ts +2 -1
- package/es/aepp-wallet-communication/connection/Browser.mjs +5 -2
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +5 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection-proxy.d.ts +1 -0
- package/es/aepp-wallet-communication/connection-proxy.mjs +1 -0
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +1 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -5
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/types.d.ts +8 -8
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
- package/es/aepp-wallet-communication/schema.d.ts +17 -2
- package/es/aepp-wallet-communication/schema.mjs +54 -17
- package/es/aepp-wallet-communication/schema.mjs.map +1 -1
- package/es/aepp-wallet-communication/wallet-detector.d.ts +2 -1
- package/es/aepp-wallet-communication/wallet-detector.mjs +2 -3
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
- package/es/apis/node/models/index.d.ts +6 -2
- package/es/apis/node/models/index.mjs.map +1 -1
- package/es/apis/node/models/mappers.mjs +4 -2
- package/es/apis/node/models/mappers.mjs.map +1 -1
- package/es/chain.d.ts +92 -64
- package/es/chain.mjs +190 -154
- package/es/chain.mjs.map +1 -1
- package/es/channel/handlers.d.ts +3 -3
- package/es/channel/handlers.mjs +42 -44
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/index.d.ts +43 -52
- package/es/channel/index.mjs +46 -49
- package/es/channel/index.mjs.map +1 -1
- package/es/channel/internal.d.ts +16 -15
- package/es/channel/internal.mjs +67 -62
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Compiler.d.ts +1 -0
- package/es/contract/Compiler.mjs +5 -4
- package/es/contract/Compiler.mjs.map +1 -1
- package/es/contract/aci.d.ts +17 -15
- package/es/contract/aci.mjs +58 -45
- package/es/contract/aci.mjs.map +1 -1
- package/es/contract/ga.d.ts +16 -15
- package/es/contract/ga.mjs +12 -7
- package/es/contract/ga.mjs.map +1 -1
- package/es/contract/methods.d.ts +9 -6
- package/es/contract/methods.mjs +9 -6
- package/es/contract/methods.mjs.map +1 -1
- package/es/deprecated/index.d.ts +143 -0
- package/es/deprecated/index.mjs +162 -0
- package/es/deprecated/index.mjs.map +1 -0
- package/es/deprecated/methods.d.ts +18 -0
- package/es/deprecated/methods.mjs +26 -0
- package/es/deprecated/methods.mjs.map +1 -0
- package/es/index.d.ts +4 -1
- package/es/index.mjs +4 -1
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +69 -62
- package/es/oracle.mjs +121 -103
- package/es/oracle.mjs.map +1 -1
- package/es/spend.d.ts +16 -15
- package/es/spend.mjs +19 -30
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/address.d.ts +25 -0
- package/es/tx/builder/address.mjs +45 -0
- package/es/tx/builder/address.mjs.map +1 -0
- package/es/tx/builder/constants.d.ts +55 -26
- package/es/tx/builder/constants.mjs +60 -38
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/coin-amount.d.ts +13 -0
- package/es/tx/builder/field-types/coin-amount.mjs +26 -0
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -0
- package/es/tx/builder/field-types/deposit.d.ts +15 -0
- package/es/tx/builder/field-types/deposit.mjs +19 -0
- package/es/tx/builder/field-types/deposit.mjs.map +1 -0
- package/es/tx/builder/field-types/fee.d.ts +25 -0
- package/es/tx/{min-fee.mjs → builder/field-types/fee.mjs} +62 -60
- package/es/tx/builder/field-types/fee.mjs.map +1 -0
- package/es/tx/builder/field-types/field.d.ts +6 -0
- package/es/tx/builder/field-types/field.mjs +15 -0
- package/es/tx/builder/field-types/field.mjs.map +1 -0
- package/es/tx/builder/field-types/gas-limit.d.ts +12 -0
- package/es/tx/builder/field-types/gas-limit.mjs +33 -0
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -0
- package/es/tx/builder/field-types/gas-price.d.ts +8 -0
- package/es/tx/builder/field-types/gas-price.mjs +18 -0
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -0
- package/es/tx/builder/field-types/index.d.ts +70 -0
- package/es/tx/builder/field-types/index.mjs +25 -0
- package/es/tx/builder/field-types/index.mjs.map +1 -0
- package/es/tx/builder/field-types/name-fee.d.ts +20 -0
- package/es/tx/builder/field-types/name-fee.mjs +24 -0
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -0
- package/es/tx/builder/field-types/name-id.d.ts +14 -0
- package/es/tx/builder/field-types/name-id.mjs +19 -0
- package/es/tx/builder/field-types/name-id.mjs.map +1 -0
- package/es/tx/builder/field-types/name.d.ts +13 -0
- package/es/tx/builder/field-types/name.mjs +18 -0
- package/es/tx/builder/field-types/name.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int.d.ts +6 -0
- package/es/tx/builder/field-types/short-u-int.mjs +12 -0
- package/es/tx/builder/field-types/short-u-int.mjs.map +1 -0
- package/es/tx/builder/field-types/u-int.d.ts +8 -0
- package/es/tx/builder/field-types/u-int.mjs +14 -0
- package/es/tx/builder/field-types/u-int.mjs.map +1 -0
- package/es/tx/builder/helpers.d.ts +27 -33
- package/es/tx/builder/helpers.mjs +41 -47
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +25 -12
- package/es/tx/builder/index.mjs +74 -83
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +995 -144
- package/es/tx/builder/schema.mjs +121 -170
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/index.d.ts +28 -27
- package/es/tx/index.mjs +97 -117
- package/es/tx/index.mjs.map +1 -1
- package/es/tx/validator.d.ts +4 -3
- package/es/tx/validator.mjs +79 -92
- package/es/tx/validator.mjs.map +1 -1
- package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -1
- package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -1
- package/es/typings/bip32-path/index.d.mjs.map +1 -1
- package/es/typings/blakejs/index.d.mjs.map +1 -1
- package/es/typings/sha-js/index.d.mjs +2 -0
- package/es/typings/sha-js/index.d.mjs.map +1 -0
- package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -1
- package/es/utils/amount-formatter.d.ts +9 -9
- package/es/utils/amount-formatter.mjs +17 -17
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.mjs +7 -7
- package/es/utils/autorest.mjs.map +1 -1
- package/es/utils/bignumber.mjs +2 -1
- package/es/utils/bignumber.mjs.map +1 -1
- package/es/utils/bytes.mjs +1 -1
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.d.ts +8 -23
- package/es/utils/crypto.mjs +15 -41
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/encoder-types.d.ts +61 -0
- package/es/utils/encoder-types.mjs +36 -0
- package/es/utils/encoder-types.mjs.map +1 -0
- package/es/utils/encoder.d.ts +6 -7
- package/es/utils/encoder.mjs +42 -26
- package/es/utils/encoder.mjs.map +1 -1
- package/es/utils/errors.d.ts +1 -11
- package/es/utils/errors.mjs +4 -20
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.d.ts +18 -2
- package/es/utils/hd-wallet.mjs +64 -34
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.mjs +2 -2
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/keystore.mjs +4 -2
- package/es/utils/keystore.mjs.map +1 -1
- package/es/utils/mptree.d.ts +2 -2
- package/es/utils/mptree.mjs +11 -6
- package/es/utils/mptree.mjs.map +1 -1
- package/es/utils/other.d.ts +8 -2
- package/es/utils/other.mjs +15 -3
- package/es/utils/other.mjs.map +1 -1
- package/es/utils/semver-satisfies.d.ts +1 -1
- package/es/utils/semver-satisfies.mjs +2 -2
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/es/utils/string.mjs.map +1 -1
- package/package.json +35 -33
- package/src/AeSdk.ts +30 -27
- package/src/AeSdkAepp.ts +93 -84
- package/src/AeSdkBase.ts +148 -130
- package/src/AeSdkWallet.ts +172 -156
- package/src/Node.ts +108 -102
- package/src/account/Base.ts +42 -32
- package/src/account/Memory.ts +45 -30
- package/src/account/Rpc.ts +32 -30
- package/src/aens.ts +124 -108
- package/src/aepp-wallet-communication/connection/Browser.ts +18 -15
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +22 -21
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +63 -52
- package/src/aepp-wallet-communication/connection-proxy.ts +8 -7
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +67 -61
- package/src/aepp-wallet-communication/rpc/types.ts +32 -32
- package/src/aepp-wallet-communication/schema.ts +117 -74
- package/src/aepp-wallet-communication/wallet-detector.ts +29 -28
- package/src/apis/node/code-model-v4.yaml +54 -20
- package/src/apis/node/models/index.ts +6 -2
- package/src/apis/node/models/mappers.ts +4 -2
- package/src/chain.ts +286 -228
- package/src/channel/handlers.ts +424 -372
- package/src/channel/index.ts +285 -251
- package/src/channel/internal.ts +248 -232
- package/src/contract/Compiler.ts +22 -21
- package/src/contract/aci.ts +267 -258
- package/src/contract/ga.ts +93 -72
- package/src/contract/methods.ts +32 -27
- package/src/deprecated/index.ts +170 -0
- package/src/deprecated/methods.ts +25 -0
- package/src/index.ts +37 -32
- package/src/oracle.ts +211 -189
- package/src/spend.ts +82 -70
- package/src/tx/builder/address.ts +50 -0
- package/src/tx/builder/constants.ts +82 -52
- package/src/tx/builder/field-types/coin-amount.ts +27 -0
- package/src/tx/builder/field-types/deposit.ts +21 -0
- package/src/tx/builder/field-types/fee.ts +143 -0
- package/src/tx/builder/field-types/field.ts +9 -0
- package/src/tx/builder/field-types/gas-limit.ts +41 -0
- package/src/tx/builder/field-types/gas-price.ts +16 -0
- package/src/tx/builder/field-types/index.ts +45 -0
- package/src/tx/builder/field-types/name-fee.ts +32 -0
- package/src/tx/builder/field-types/name-id.ts +20 -0
- package/src/tx/builder/field-types/name.ts +18 -0
- package/src/tx/builder/field-types/short-u-int.ts +11 -0
- package/src/tx/builder/field-types/u-int.ts +16 -0
- package/src/tx/builder/helpers.ts +112 -117
- package/src/tx/builder/index.ts +203 -197
- package/src/tx/builder/schema.ts +421 -465
- package/src/tx/index.ts +128 -135
- package/src/tx/validator.ts +165 -161
- package/src/typings/@aeternity__argon2-browser/index.d.ts +1 -1
- package/src/typings/@aeternity__uuid/index.d.ts +3 -1
- package/src/typings/bip32-path/index.d.ts +6 -6
- package/src/typings/blakejs/index.d.ts +4 -32
- package/src/typings/sha-js/index.d.ts +5 -0
- package/src/typings/tweetnacl-auth/index.d.ts +2 -2
- package/src/utils/amount-formatter.ts +41 -41
- package/src/utils/autorest.ts +57 -54
- package/src/utils/bignumber.ts +7 -6
- package/src/utils/bytes.ts +19 -19
- package/src/utils/crypto.ts +82 -94
- package/src/utils/encoder-types.ts +63 -0
- package/src/utils/encoder.ts +104 -56
- package/src/utils/errors.ts +246 -264
- package/src/utils/hd-wallet.ts +114 -82
- package/src/utils/json-big.ts +16 -15
- package/src/utils/keystore.ts +65 -62
- package/src/utils/mptree.ts +59 -56
- package/src/utils/other.ts +26 -18
- package/src/utils/semver-satisfies.ts +15 -11
- package/src/utils/string.ts +10 -10
- package/es/tx/builder/field-types.d.ts +0 -62
- package/es/tx/builder/field-types.mjs +0 -126
- package/es/tx/builder/field-types.mjs.map +0 -1
- package/es/tx/min-fee.d.ts +0 -20
- package/es/tx/min-fee.mjs.map +0 -1
- package/src/tx/builder/field-types.ts +0 -111
- package/src/tx/min-fee.ts +0 -136
package/src/AeSdkAepp.ts
CHANGED
|
@@ -1,31 +1,39 @@
|
|
|
1
|
-
import AeSdkBase, { Account } from './AeSdkBase'
|
|
2
|
-
import AccountBase from './account/Base'
|
|
3
|
-
import AccountRpc from './account/Rpc'
|
|
4
|
-
import { decode,
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import AeSdkBase, { Account } from './AeSdkBase';
|
|
2
|
+
import AccountBase from './account/Base';
|
|
3
|
+
import AccountRpc from './account/Rpc';
|
|
4
|
+
import { decode, Encoded } from './utils/encoder';
|
|
5
|
+
import {
|
|
6
|
+
Accounts, RPC_VERSION, WalletInfo, Network, WalletApi, AeppApi,
|
|
7
|
+
} from './aepp-wallet-communication/rpc/types';
|
|
8
|
+
import RpcClient from './aepp-wallet-communication/rpc/RpcClient';
|
|
9
|
+
import { METHODS, SUBSCRIPTION_TYPES } from './aepp-wallet-communication/schema';
|
|
8
10
|
import {
|
|
9
11
|
AlreadyConnectedError,
|
|
10
12
|
NoWalletConnectedError,
|
|
11
13
|
UnsubscribedAccountError,
|
|
12
14
|
UnAuthorizedAccountError,
|
|
13
|
-
RpcConnectionError
|
|
14
|
-
} from './utils/errors'
|
|
15
|
-
import Node from './Node'
|
|
16
|
-
import BrowserConnection from './aepp-wallet-communication/connection/Browser'
|
|
15
|
+
RpcConnectionError,
|
|
16
|
+
} from './utils/errors';
|
|
17
|
+
import Node from './Node';
|
|
18
|
+
import BrowserConnection from './aepp-wallet-communication/connection/Browser';
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* RPC handler for AEPP side
|
|
20
22
|
* Contain functionality for wallet interaction and connect it to sdk
|
|
23
|
+
* @category aepp wallet communication
|
|
21
24
|
*/
|
|
22
25
|
export default class AeSdkAepp extends AeSdkBase {
|
|
23
|
-
name: string
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
name: string;
|
|
27
|
+
|
|
28
|
+
onAddressChange: (a: Accounts) => void;
|
|
29
|
+
|
|
30
|
+
onDisconnect: (p: any) => void;
|
|
31
|
+
|
|
32
|
+
onNetworkChange: (a: Network) => void;
|
|
33
|
+
|
|
34
|
+
rpcClient?: RpcClient<WalletApi, AeppApi>;
|
|
35
|
+
|
|
36
|
+
_accounts?: Accounts;
|
|
29
37
|
|
|
30
38
|
/**
|
|
31
39
|
* @param options - Options
|
|
@@ -34,42 +42,42 @@ export default class AeSdkAepp extends AeSdkBase {
|
|
|
34
42
|
* @param options.onDisconnect - Call-back function for disconnect event
|
|
35
43
|
* @param options.onNetworkChange - Call-back function for update network event
|
|
36
44
|
*/
|
|
37
|
-
constructor
|
|
45
|
+
constructor({
|
|
38
46
|
name,
|
|
39
47
|
onAddressChange = () => {},
|
|
40
48
|
onDisconnect = () => {},
|
|
41
49
|
onNetworkChange = () => {},
|
|
42
50
|
...other
|
|
43
51
|
}: {
|
|
44
|
-
name: string
|
|
45
|
-
onAddressChange: (a: Accounts) => void
|
|
46
|
-
onDisconnect: (p: any) => void
|
|
47
|
-
onNetworkChange: (a: Network) => void
|
|
52
|
+
name: string;
|
|
53
|
+
onAddressChange: (a: Accounts) => void;
|
|
54
|
+
onDisconnect: (p: any) => void;
|
|
55
|
+
onNetworkChange: (a: Network) => void;
|
|
48
56
|
} & ConstructorParameters<typeof AeSdkBase>[0]) {
|
|
49
|
-
super(other)
|
|
50
|
-
this.onAddressChange = onAddressChange
|
|
51
|
-
this.onDisconnect = onDisconnect
|
|
52
|
-
this.onNetworkChange = onNetworkChange
|
|
53
|
-
this.name = name
|
|
57
|
+
super(other);
|
|
58
|
+
this.onAddressChange = onAddressChange;
|
|
59
|
+
this.onDisconnect = onDisconnect;
|
|
60
|
+
this.onNetworkChange = onNetworkChange;
|
|
61
|
+
this.name = name;
|
|
54
62
|
}
|
|
55
63
|
|
|
56
|
-
_resolveAccount
|
|
64
|
+
_resolveAccount(account: Account = this.addresses()[0]): AccountBase {
|
|
57
65
|
if (typeof account === 'string') {
|
|
58
|
-
const address = account as
|
|
59
|
-
decode(address)
|
|
60
|
-
if (!this.addresses().includes(address)) throw new UnAuthorizedAccountError(address)
|
|
61
|
-
account = new AccountRpc({ rpcClient: this.rpcClient, address })
|
|
66
|
+
const address = account as Encoded.AccountAddress;
|
|
67
|
+
decode(address);
|
|
68
|
+
if (!this.addresses().includes(address)) throw new UnAuthorizedAccountError(address);
|
|
69
|
+
account = new AccountRpc({ rpcClient: this.rpcClient, address });
|
|
62
70
|
}
|
|
63
|
-
if (account == null) this._ensureAccountAccess()
|
|
64
|
-
return super._resolveAccount(account)
|
|
71
|
+
if (account == null) this._ensureAccountAccess();
|
|
72
|
+
return super._resolveAccount(account);
|
|
65
73
|
}
|
|
66
74
|
|
|
67
|
-
addresses
|
|
68
|
-
if (this._accounts == null) return []
|
|
69
|
-
const current = Object.keys(this._accounts.current)[0]
|
|
75
|
+
addresses(): Encoded.AccountAddress[] {
|
|
76
|
+
if (this._accounts == null) return [];
|
|
77
|
+
const current = Object.keys(this._accounts.current)[0];
|
|
70
78
|
return [
|
|
71
|
-
...current != null ? [current] : [], ...Object.keys(this._accounts.connected)
|
|
72
|
-
] as
|
|
79
|
+
...current != null ? [current] : [], ...Object.keys(this._accounts.connected),
|
|
80
|
+
] as Encoded.AccountAddress[];
|
|
73
81
|
}
|
|
74
82
|
|
|
75
83
|
/**
|
|
@@ -80,63 +88,63 @@ export default class AeSdkAepp extends AeSdkBase {
|
|
|
80
88
|
* @param options.name - Node name
|
|
81
89
|
* @param options.select - Select this node as current
|
|
82
90
|
*/
|
|
83
|
-
async connectToWallet
|
|
91
|
+
async connectToWallet(
|
|
84
92
|
connection: BrowserConnection,
|
|
85
93
|
{ connectNode = false, name = 'wallet-node', select = false }:
|
|
86
|
-
{ connectNode?: boolean
|
|
94
|
+
{ connectNode?: boolean; name?: string; select?: boolean } = {},
|
|
87
95
|
): Promise<WalletInfo> {
|
|
88
|
-
if (this.rpcClient != null) throw new AlreadyConnectedError('You are already connected to wallet')
|
|
89
|
-
let disconnectParams: any
|
|
96
|
+
if (this.rpcClient != null) throw new AlreadyConnectedError('You are already connected to wallet');
|
|
97
|
+
let disconnectParams: any;
|
|
90
98
|
const client = new RpcClient<WalletApi, AeppApi>(
|
|
91
99
|
connection,
|
|
92
100
|
() => {
|
|
93
|
-
delete this.rpcClient
|
|
94
|
-
delete this._accounts
|
|
95
|
-
this.onDisconnect(disconnectParams)
|
|
96
|
-
},
|
|
101
|
+
delete this.rpcClient;
|
|
102
|
+
delete this._accounts;
|
|
103
|
+
this.onDisconnect(disconnectParams);
|
|
104
|
+
},
|
|
105
|
+
{
|
|
97
106
|
[METHODS.updateAddress]: (params) => {
|
|
98
|
-
this._accounts = params
|
|
99
|
-
this.onAddressChange(params)
|
|
107
|
+
this._accounts = params;
|
|
108
|
+
this.onAddressChange(params);
|
|
100
109
|
},
|
|
101
110
|
[METHODS.updateNetwork]: (params) => {
|
|
102
|
-
const { node } = params
|
|
103
|
-
if (node != null) this.addNode(node.name, new Node(node.url), true)
|
|
104
|
-
this.onNetworkChange(params)
|
|
111
|
+
const { node } = params;
|
|
112
|
+
if (node != null) this.addNode(node.name, new Node(node.url), true);
|
|
113
|
+
this.onNetworkChange(params);
|
|
105
114
|
},
|
|
106
115
|
[METHODS.closeConnection]: (params) => {
|
|
107
|
-
disconnectParams = params
|
|
108
|
-
client.connection.disconnect()
|
|
116
|
+
disconnectParams = params;
|
|
117
|
+
client.connection.disconnect();
|
|
109
118
|
},
|
|
110
|
-
[METHODS.readyToConnect]: () => {}
|
|
111
|
-
}
|
|
112
|
-
)
|
|
113
|
-
const { node, ...walletInfo } = await client
|
|
114
|
-
METHODS.connect, { name: this.name, version: RPC_VERSION, connectNode }
|
|
115
|
-
)
|
|
119
|
+
[METHODS.readyToConnect]: () => {},
|
|
120
|
+
},
|
|
121
|
+
);
|
|
122
|
+
const { node, ...walletInfo } = await client
|
|
123
|
+
.request(METHODS.connect, { name: this.name, version: RPC_VERSION, connectNode });
|
|
116
124
|
if (connectNode) {
|
|
117
|
-
if (node == null) throw new RpcConnectionError('Missing URLs of the Node')
|
|
118
|
-
this.addNode(name, new Node(node.url), select)
|
|
125
|
+
if (node == null) throw new RpcConnectionError('Missing URLs of the Node');
|
|
126
|
+
this.addNode(name, new Node(node.url), select);
|
|
119
127
|
}
|
|
120
|
-
this.rpcClient = client
|
|
121
|
-
return walletInfo
|
|
128
|
+
this.rpcClient = client;
|
|
129
|
+
return walletInfo;
|
|
122
130
|
}
|
|
123
131
|
|
|
124
132
|
/**
|
|
125
133
|
* Disconnect from wallet
|
|
126
134
|
*/
|
|
127
|
-
disconnectWallet
|
|
128
|
-
this._ensureConnected()
|
|
129
|
-
this.rpcClient.notify(METHODS.closeConnection, { reason: 'bye' })
|
|
130
|
-
this.rpcClient.connection.disconnect()
|
|
135
|
+
disconnectWallet(): void {
|
|
136
|
+
this._ensureConnected();
|
|
137
|
+
this.rpcClient.notify(METHODS.closeConnection, { reason: 'bye' });
|
|
138
|
+
this.rpcClient.connection.disconnect();
|
|
131
139
|
}
|
|
132
140
|
|
|
133
141
|
/**
|
|
134
142
|
* Ask addresses from wallet
|
|
135
143
|
* @returns Addresses from wallet
|
|
136
144
|
*/
|
|
137
|
-
async askAddresses
|
|
138
|
-
this._ensureAccountAccess()
|
|
139
|
-
return
|
|
145
|
+
async askAddresses(): Promise<Encoded.AccountAddress[]> {
|
|
146
|
+
this._ensureAccountAccess();
|
|
147
|
+
return this.rpcClient.request(METHODS.address, undefined);
|
|
140
148
|
}
|
|
141
149
|
|
|
142
150
|
/**
|
|
@@ -145,23 +153,24 @@ export default class AeSdkAepp extends AeSdkBase {
|
|
|
145
153
|
* @param value - Should be one of 'current' (the selected account), 'connected' (all)
|
|
146
154
|
* @returns Accounts from wallet
|
|
147
155
|
*/
|
|
148
|
-
async subscribeAddress
|
|
149
|
-
type: SUBSCRIPTION_TYPES,
|
|
156
|
+
async subscribeAddress(
|
|
157
|
+
type: SUBSCRIPTION_TYPES,
|
|
158
|
+
value: 'current' | 'connected',
|
|
150
159
|
): Promise<ReturnType<WalletApi[METHODS.subscribeAddress]>> {
|
|
151
|
-
this._ensureConnected()
|
|
152
|
-
const result = await this.rpcClient.request(METHODS.subscribeAddress, { type, value })
|
|
153
|
-
this._accounts = result.address
|
|
154
|
-
return result
|
|
160
|
+
this._ensureConnected();
|
|
161
|
+
const result = await this.rpcClient.request(METHODS.subscribeAddress, { type, value });
|
|
162
|
+
this._accounts = result.address;
|
|
163
|
+
return result;
|
|
155
164
|
}
|
|
156
165
|
|
|
157
|
-
_ensureConnected
|
|
158
|
-
if (this.rpcClient != null) return
|
|
159
|
-
throw new NoWalletConnectedError('You are not connected to Wallet')
|
|
166
|
+
_ensureConnected(): asserts this is AeSdkAepp & { rpcClient: NonNullable<AeSdkAepp['rpcClient']> } {
|
|
167
|
+
if (this.rpcClient != null) return;
|
|
168
|
+
throw new NoWalletConnectedError('You are not connected to Wallet');
|
|
160
169
|
}
|
|
161
170
|
|
|
162
|
-
_ensureAccountAccess
|
|
163
|
-
this._ensureConnected()
|
|
164
|
-
if (this.addresses().length !== 0) return
|
|
165
|
-
throw new UnsubscribedAccountError()
|
|
171
|
+
_ensureAccountAccess(): asserts this is AeSdkAepp & { rpcClient: NonNullable<AeSdkAepp['rpcClient']> } {
|
|
172
|
+
this._ensureConnected();
|
|
173
|
+
if (this.addresses().length !== 0) return;
|
|
174
|
+
throw new UnsubscribedAccountError();
|
|
166
175
|
}
|
|
167
176
|
}
|