@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
|
@@ -1,21 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
// eslint-disable-next-line max-classes-per-file
|
|
2
|
+
import { Encoded } from '../utils/encoder';
|
|
3
|
+
import { BaseError, InternalError } from '../utils/errors';
|
|
3
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @category aepp wallet communication
|
|
7
|
+
*/
|
|
4
8
|
export const enum MESSAGE_DIRECTION {
|
|
5
9
|
to_waellet = 'to_waellet',
|
|
6
|
-
to_aepp = 'to_aepp'
|
|
10
|
+
to_aepp = 'to_aepp',
|
|
7
11
|
}
|
|
8
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @category aepp wallet communication
|
|
15
|
+
*/
|
|
9
16
|
export const enum WALLET_TYPE {
|
|
10
17
|
window = 'window',
|
|
11
|
-
extension = 'extension'
|
|
18
|
+
extension = 'extension',
|
|
12
19
|
}
|
|
13
20
|
|
|
21
|
+
/**
|
|
22
|
+
* @category aepp wallet communication
|
|
23
|
+
*/
|
|
14
24
|
export const enum SUBSCRIPTION_TYPES {
|
|
15
25
|
subscribe = 'subscribe',
|
|
16
|
-
unsubscribe = 'unsubscribe'
|
|
26
|
+
unsubscribe = 'unsubscribe',
|
|
17
27
|
}
|
|
18
28
|
|
|
29
|
+
/**
|
|
30
|
+
* @category aepp wallet communication
|
|
31
|
+
*/
|
|
19
32
|
export const enum METHODS {
|
|
20
33
|
readyToConnect = 'connection.announcePresence',
|
|
21
34
|
updateAddress = 'address.update',
|
|
@@ -25,45 +38,48 @@ export const enum METHODS {
|
|
|
25
38
|
signMessage = 'message.sign',
|
|
26
39
|
subscribeAddress = 'address.subscribe',
|
|
27
40
|
updateNetwork = 'networkId.update',
|
|
28
|
-
closeConnection = 'connection.close'
|
|
41
|
+
closeConnection = 'connection.close',
|
|
29
42
|
}
|
|
30
43
|
|
|
44
|
+
/**
|
|
45
|
+
* @category aepp wallet communication
|
|
46
|
+
*/
|
|
31
47
|
export const enum RPC_STATUS {
|
|
32
48
|
CONNECTED = 'CONNECTED',
|
|
33
49
|
DISCONNECTED = 'DISCONNECTED',
|
|
34
|
-
WAITING_FOR_CONNECTION_REQUEST = 'WAITING_FOR_CONNECTION_REQUEST'
|
|
50
|
+
WAITING_FOR_CONNECTION_REQUEST = 'WAITING_FOR_CONNECTION_REQUEST',
|
|
35
51
|
}
|
|
36
52
|
|
|
37
53
|
interface RpcErrorAsJson {
|
|
38
|
-
code: number
|
|
39
|
-
message: string
|
|
40
|
-
data?: any
|
|
54
|
+
code: number;
|
|
55
|
+
message: string;
|
|
56
|
+
data?: any;
|
|
41
57
|
}
|
|
42
58
|
|
|
59
|
+
const rpcErrors: Array<(new (data?: any) => RpcError) & { code: number }> = [];
|
|
60
|
+
|
|
43
61
|
/**
|
|
44
62
|
* @category exception
|
|
45
63
|
*/
|
|
46
64
|
export abstract class RpcError extends BaseError {
|
|
47
|
-
static code: number
|
|
48
|
-
|
|
49
|
-
|
|
65
|
+
static code: number;
|
|
66
|
+
|
|
67
|
+
code: number;
|
|
50
68
|
|
|
51
|
-
|
|
69
|
+
data?: any;
|
|
70
|
+
|
|
71
|
+
toJSON(): RpcErrorAsJson {
|
|
52
72
|
return {
|
|
53
73
|
code: this.code,
|
|
54
74
|
message: this.message,
|
|
55
|
-
data: this.data
|
|
56
|
-
}
|
|
75
|
+
data: this.data,
|
|
76
|
+
};
|
|
57
77
|
}
|
|
58
78
|
|
|
59
|
-
static deserialize
|
|
60
|
-
const RpcErr =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
RpcPermissionDenyError, RpcInternalError
|
|
64
|
-
].find(cl => cl.code === json.code)
|
|
65
|
-
if (RpcErr == null) throw new InternalError(`Can't find RpcError with code: ${json.code}`)
|
|
66
|
-
return new RpcErr(json.data)
|
|
79
|
+
static deserialize(json: RpcErrorAsJson): RpcError {
|
|
80
|
+
const RpcErr = rpcErrors.find((cl) => cl.code === json.code);
|
|
81
|
+
if (RpcErr == null) throw new InternalError(`Can't find RpcError with code: ${json.code}`);
|
|
82
|
+
return new RpcErr(json.data);
|
|
67
83
|
}
|
|
68
84
|
}
|
|
69
85
|
|
|
@@ -71,111 +87,138 @@ export abstract class RpcError extends BaseError {
|
|
|
71
87
|
* @category exception
|
|
72
88
|
*/
|
|
73
89
|
export class RpcInvalidTransactionError extends RpcError {
|
|
74
|
-
static code = 2
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
90
|
+
static code = 2;
|
|
91
|
+
|
|
92
|
+
code = 2;
|
|
93
|
+
|
|
94
|
+
constructor(data?: any) {
|
|
95
|
+
super('Invalid transaction');
|
|
96
|
+
this.data = data;
|
|
97
|
+
this.name = 'RpcInvalidTransactionError';
|
|
80
98
|
}
|
|
81
99
|
}
|
|
100
|
+
rpcErrors.push(RpcInvalidTransactionError);
|
|
82
101
|
|
|
83
102
|
/**
|
|
84
103
|
* @category exception
|
|
85
104
|
*/
|
|
86
105
|
export class RpcBroadcastError extends RpcError {
|
|
87
|
-
static code = 3
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
106
|
+
static code = 3;
|
|
107
|
+
|
|
108
|
+
code = 3;
|
|
109
|
+
|
|
110
|
+
constructor(data?: any) {
|
|
111
|
+
super('Broadcast failed');
|
|
112
|
+
this.data = data;
|
|
113
|
+
this.name = 'RpcBroadcastError';
|
|
93
114
|
}
|
|
94
115
|
}
|
|
116
|
+
rpcErrors.push(RpcBroadcastError);
|
|
95
117
|
|
|
96
118
|
/**
|
|
97
119
|
* @category exception
|
|
98
120
|
*/
|
|
99
121
|
export class RpcRejectedByUserError extends RpcError {
|
|
100
|
-
static code = 4
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
122
|
+
static code = 4;
|
|
123
|
+
|
|
124
|
+
code = 4;
|
|
125
|
+
|
|
126
|
+
constructor(data?: any) {
|
|
127
|
+
super('Operation rejected by user');
|
|
128
|
+
this.data = data;
|
|
129
|
+
this.name = 'RpcRejectedByUserError';
|
|
106
130
|
}
|
|
107
131
|
}
|
|
132
|
+
rpcErrors.push(RpcRejectedByUserError);
|
|
108
133
|
|
|
109
134
|
/**
|
|
110
135
|
* @category exception
|
|
111
136
|
*/
|
|
112
137
|
export class RpcUnsupportedProtocolError extends RpcError {
|
|
113
|
-
static code = 5
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
138
|
+
static code = 5;
|
|
139
|
+
|
|
140
|
+
code = 5;
|
|
141
|
+
|
|
142
|
+
constructor() {
|
|
143
|
+
super('Unsupported Protocol Version');
|
|
144
|
+
this.name = 'RpcUnsupportedProtocolError';
|
|
118
145
|
}
|
|
119
146
|
}
|
|
147
|
+
rpcErrors.push(RpcUnsupportedProtocolError);
|
|
120
148
|
|
|
121
149
|
/**
|
|
122
150
|
* @category exception
|
|
123
151
|
*/
|
|
124
152
|
export class RpcConnectionDenyError extends RpcError {
|
|
125
|
-
static code = 9
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
153
|
+
static code = 9;
|
|
154
|
+
|
|
155
|
+
code = 9;
|
|
156
|
+
|
|
157
|
+
constructor(data?: any) {
|
|
158
|
+
super('Wallet deny your connection request');
|
|
159
|
+
this.data = data;
|
|
160
|
+
this.name = 'RpcConnectionDenyError';
|
|
131
161
|
}
|
|
132
162
|
}
|
|
163
|
+
rpcErrors.push(RpcConnectionDenyError);
|
|
133
164
|
|
|
134
165
|
/**
|
|
135
166
|
* @category exception
|
|
136
167
|
*/
|
|
137
168
|
export class RpcNotAuthorizeError extends RpcError {
|
|
138
|
-
static code = 10
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
169
|
+
static code = 10;
|
|
170
|
+
|
|
171
|
+
code = 10;
|
|
172
|
+
|
|
173
|
+
constructor() {
|
|
174
|
+
super('You are not connected to the wallet');
|
|
175
|
+
this.name = 'RpcNotAuthorizeError';
|
|
143
176
|
}
|
|
144
177
|
}
|
|
178
|
+
rpcErrors.push(RpcNotAuthorizeError);
|
|
145
179
|
|
|
146
180
|
/**
|
|
147
181
|
* @category exception
|
|
148
182
|
*/
|
|
149
183
|
export class RpcPermissionDenyError extends RpcError {
|
|
150
|
-
static code = 11
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
184
|
+
static code = 11;
|
|
185
|
+
|
|
186
|
+
code = 11;
|
|
187
|
+
|
|
188
|
+
constructor(address: Encoded.AccountAddress) {
|
|
189
|
+
super(`You are not subscribed for account ${address}`);
|
|
190
|
+
this.data = address;
|
|
191
|
+
this.name = 'RpcPermissionDenyError';
|
|
156
192
|
}
|
|
157
193
|
}
|
|
194
|
+
rpcErrors.push(RpcPermissionDenyError);
|
|
158
195
|
|
|
159
196
|
/**
|
|
160
197
|
* @category exception
|
|
161
198
|
*/
|
|
162
199
|
export class RpcInternalError extends RpcError {
|
|
163
|
-
static code = 12
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
200
|
+
static code = 12;
|
|
201
|
+
|
|
202
|
+
code = 12;
|
|
203
|
+
|
|
204
|
+
constructor() {
|
|
205
|
+
super('The peer failed to execute your request due to unknown error');
|
|
206
|
+
this.name = 'RpcInternalError';
|
|
168
207
|
}
|
|
169
208
|
}
|
|
209
|
+
rpcErrors.push(RpcInternalError);
|
|
170
210
|
|
|
171
211
|
/**
|
|
172
212
|
* @category exception
|
|
173
213
|
*/
|
|
174
214
|
export class RpcMethodNotFoundError extends RpcError {
|
|
175
|
-
static code = -32601
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
215
|
+
static code = -32601;
|
|
216
|
+
|
|
217
|
+
code = -32601;
|
|
218
|
+
|
|
219
|
+
constructor() {
|
|
220
|
+
super('Method not found');
|
|
221
|
+
this.name = 'RpcMethodNotFoundError';
|
|
180
222
|
}
|
|
181
223
|
}
|
|
224
|
+
rpcErrors.push(RpcMethodNotFoundError);
|
|
@@ -15,57 +15,58 @@
|
|
|
15
15
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import BrowserConnection from './connection/Browser'
|
|
19
|
-
import BrowserWindowMessageConnection from './connection/BrowserWindowMessage'
|
|
20
|
-
import { MESSAGE_DIRECTION, METHODS } from './schema'
|
|
21
|
-
import { UnsupportedPlatformError } from '../utils/errors'
|
|
18
|
+
import BrowserConnection from './connection/Browser';
|
|
19
|
+
import BrowserWindowMessageConnection from './connection/BrowserWindowMessage';
|
|
20
|
+
import { MESSAGE_DIRECTION, METHODS } from './schema';
|
|
21
|
+
import { UnsupportedPlatformError } from '../utils/errors';
|
|
22
22
|
|
|
23
23
|
interface Wallet {
|
|
24
24
|
info: {
|
|
25
|
-
id: string
|
|
26
|
-
type: string
|
|
27
|
-
origin: string
|
|
28
|
-
}
|
|
29
|
-
getConnection: () => BrowserWindowMessageConnection
|
|
25
|
+
id: string;
|
|
26
|
+
type: string;
|
|
27
|
+
origin: string;
|
|
28
|
+
};
|
|
29
|
+
getConnection: () => BrowserWindowMessageConnection;
|
|
30
30
|
}
|
|
31
31
|
interface Wallets { [key: string]: Wallet }
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* A function to detect available wallets
|
|
35
|
+
* @category aepp wallet communication
|
|
35
36
|
* @param connection - connection to use to detect wallets
|
|
36
37
|
* @param onDetected - call-back function which trigger on new wallet
|
|
37
38
|
* @returns a function to stop scanning
|
|
38
39
|
*/
|
|
39
40
|
export default (
|
|
40
|
-
connection: BrowserConnection
|
|
41
|
-
onDetected: ({ wallets, newWallet }: { wallets: Wallets
|
|
41
|
+
connection: BrowserConnection,
|
|
42
|
+
onDetected: ({ wallets, newWallet }: { wallets: Wallets; newWallet?: Wallet }) => void,
|
|
42
43
|
): () => void => {
|
|
43
|
-
if (window == null) throw new UnsupportedPlatformError('Window object not found, you can run wallet detector only in browser')
|
|
44
|
-
const wallets: Wallets = {}
|
|
44
|
+
if (window == null) throw new UnsupportedPlatformError('Window object not found, you can run wallet detector only in browser');
|
|
45
|
+
const wallets: Wallets = {};
|
|
45
46
|
|
|
46
47
|
connection.connect((
|
|
47
|
-
{ method, params }: { method: string
|
|
48
|
+
{ method, params }: { method: string; params: Wallet['info'] },
|
|
48
49
|
origin: string,
|
|
49
|
-
source: Window
|
|
50
|
+
source: Window,
|
|
50
51
|
) => {
|
|
51
|
-
if (method !== METHODS.readyToConnect || wallets[params.id] != null) return
|
|
52
|
+
if (method !== METHODS.readyToConnect || wallets[params.id] != null) return;
|
|
52
53
|
|
|
53
54
|
const wallet = {
|
|
54
55
|
info: params,
|
|
55
|
-
getConnection
|
|
56
|
-
const isExtension = params.type === 'extension'
|
|
56
|
+
getConnection() {
|
|
57
|
+
const isExtension = params.type === 'extension';
|
|
57
58
|
return new BrowserWindowMessageConnection({
|
|
58
59
|
sendDirection: isExtension ? MESSAGE_DIRECTION.to_waellet : undefined,
|
|
59
60
|
receiveDirection: isExtension ? MESSAGE_DIRECTION.to_aepp : undefined,
|
|
60
61
|
target: source,
|
|
61
|
-
origin: isExtension ? window.origin : params.origin
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
wallets[wallet.info.id] = wallet
|
|
66
|
-
onDetected({ wallets, newWallet: wallet })
|
|
67
|
-
}, () => {})
|
|
68
|
-
if (Object.keys(wallets).length > 0) onDetected({ wallets })
|
|
62
|
+
origin: isExtension ? window.origin : params.origin,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
wallets[wallet.info.id] = wallet;
|
|
67
|
+
onDetected({ wallets, newWallet: wallet });
|
|
68
|
+
}, () => {});
|
|
69
|
+
if (Object.keys(wallets).length > 0) onDetected({ wallets });
|
|
69
70
|
|
|
70
|
-
return () => connection.disconnect()
|
|
71
|
-
}
|
|
71
|
+
return () => connection.disconnect();
|
|
72
|
+
};
|
|
@@ -352,26 +352,6 @@ schemas: !Schemas
|
|
|
352
352
|
name: DryRunResultReason
|
|
353
353
|
description: ''
|
|
354
354
|
protocol: !Protocols {}
|
|
355
|
-
- !StringSchema &ref_57
|
|
356
|
-
type: string
|
|
357
|
-
apiVersions:
|
|
358
|
-
- !ApiVersion
|
|
359
|
-
version: x.y.z
|
|
360
|
-
language: !Languages
|
|
361
|
-
default:
|
|
362
|
-
name: ContractCallObjectReturnType
|
|
363
|
-
description: The status of the call 'ok | error | revert'.
|
|
364
|
-
protocol: !Protocols {}
|
|
365
|
-
- !StringSchema &ref_62
|
|
366
|
-
type: string
|
|
367
|
-
apiVersions:
|
|
368
|
-
- !ApiVersion
|
|
369
|
-
version: x.y.z
|
|
370
|
-
language: !Languages
|
|
371
|
-
default:
|
|
372
|
-
name: GAObjectReturnType
|
|
373
|
-
description: The status of the call 'ok | error'.
|
|
374
|
-
protocol: !Protocols {}
|
|
375
355
|
- !StringSchema &ref_64
|
|
376
356
|
type: string
|
|
377
357
|
apiVersions:
|
|
@@ -829,6 +809,60 @@ schemas: !Schemas
|
|
|
829
809
|
name: NextNonceStrategy
|
|
830
810
|
description: ''
|
|
831
811
|
protocol: !Protocols {}
|
|
812
|
+
- !SealedChoiceSchema &ref_57
|
|
813
|
+
choices:
|
|
814
|
+
- !ChoiceValue
|
|
815
|
+
value: ok
|
|
816
|
+
language:
|
|
817
|
+
default:
|
|
818
|
+
name: Ok
|
|
819
|
+
description: ''
|
|
820
|
+
- !ChoiceValue
|
|
821
|
+
value: error
|
|
822
|
+
language:
|
|
823
|
+
default:
|
|
824
|
+
name: Error
|
|
825
|
+
description: ''
|
|
826
|
+
- !ChoiceValue
|
|
827
|
+
value: revert
|
|
828
|
+
language:
|
|
829
|
+
default:
|
|
830
|
+
name: Revert
|
|
831
|
+
description: ''
|
|
832
|
+
type: sealed-choice
|
|
833
|
+
apiVersions:
|
|
834
|
+
- !ApiVersion
|
|
835
|
+
version: x.y.z
|
|
836
|
+
choiceType: *ref_0
|
|
837
|
+
language: !Languages
|
|
838
|
+
default:
|
|
839
|
+
name: ContractCallReturnType
|
|
840
|
+
description: The status of the call 'ok | error | revert'.
|
|
841
|
+
protocol: !Protocols {}
|
|
842
|
+
- !SealedChoiceSchema &ref_62
|
|
843
|
+
choices:
|
|
844
|
+
- !ChoiceValue
|
|
845
|
+
value: ok
|
|
846
|
+
language:
|
|
847
|
+
default:
|
|
848
|
+
name: Ok
|
|
849
|
+
description: ''
|
|
850
|
+
- !ChoiceValue
|
|
851
|
+
value: error
|
|
852
|
+
language:
|
|
853
|
+
default:
|
|
854
|
+
name: Error
|
|
855
|
+
description: ''
|
|
856
|
+
type: sealed-choice
|
|
857
|
+
apiVersions:
|
|
858
|
+
- !ApiVersion
|
|
859
|
+
version: x.y.z
|
|
860
|
+
choiceType: *ref_0
|
|
861
|
+
language: !Languages
|
|
862
|
+
default:
|
|
863
|
+
name: GAReturnType
|
|
864
|
+
description: The status of the call 'ok | error'.
|
|
865
|
+
protocol: !Protocols {}
|
|
832
866
|
- !SealedChoiceSchema &ref_169
|
|
833
867
|
choices:
|
|
834
868
|
- !ChoiceValue
|
|
@@ -332,7 +332,7 @@ export interface ContractCallObject {
|
|
|
332
332
|
/** Base64Check encoded tagged byte array */
|
|
333
333
|
returnValue: string;
|
|
334
334
|
/** The status of the call 'ok | error | revert'. */
|
|
335
|
-
returnType:
|
|
335
|
+
returnType: ContractCallReturnType;
|
|
336
336
|
}
|
|
337
337
|
|
|
338
338
|
export interface Event {
|
|
@@ -359,7 +359,7 @@ export interface GAObject {
|
|
|
359
359
|
/** Base64Check encoded tagged byte array */
|
|
360
360
|
returnValue: string;
|
|
361
361
|
/** The status of the call 'ok | error'. */
|
|
362
|
-
returnType:
|
|
362
|
+
returnType: GAReturnType;
|
|
363
363
|
innerObject?: TxInfoObject;
|
|
364
364
|
}
|
|
365
365
|
|
|
@@ -991,6 +991,10 @@ export type TxType =
|
|
|
991
991
|
export type AccountKind = "basic" | "generalized";
|
|
992
992
|
/** Defines values for NextNonceStrategy. */
|
|
993
993
|
export type NextNonceStrategy = "max" | "continuity";
|
|
994
|
+
/** Defines values for ContractCallReturnType. */
|
|
995
|
+
export type ContractCallReturnType = "ok" | "error" | "revert";
|
|
996
|
+
/** Defines values for GAReturnType. */
|
|
997
|
+
export type GAReturnType = "ok" | "error";
|
|
994
998
|
/** Defines values for OracleQueryType. */
|
|
995
999
|
export type OracleQueryType = "open" | "closed" | "all";
|
|
996
1000
|
|
|
@@ -1425,7 +1425,8 @@ export const ContractCallObject: coreClient.CompositeMapper = {
|
|
|
1425
1425
|
serializedName: "return_type",
|
|
1426
1426
|
required: true,
|
|
1427
1427
|
type: {
|
|
1428
|
-
name: "
|
|
1428
|
+
name: "Enum",
|
|
1429
|
+
allowedValues: ["ok", "error", "revert"]
|
|
1429
1430
|
}
|
|
1430
1431
|
}
|
|
1431
1432
|
}
|
|
@@ -1540,7 +1541,8 @@ export const GAObject: coreClient.CompositeMapper = {
|
|
|
1540
1541
|
serializedName: "return_type",
|
|
1541
1542
|
required: true,
|
|
1542
1543
|
type: {
|
|
1543
|
-
name: "
|
|
1544
|
+
name: "Enum",
|
|
1545
|
+
allowedValues: ["ok", "error"]
|
|
1544
1546
|
}
|
|
1545
1547
|
},
|
|
1546
1548
|
innerObject: {
|