@aeternity/aepp-sdk 13.0.1 → 13.2.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/README.md +4 -2
- package/bin/aesophia_cli +0 -0
- package/dist/aepp-sdk.browser-script.js +1 -1
- 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 +28490 -17706
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdkAepp.mjs.map +1 -1
- package/es/AeSdkBase.d.ts +21 -3
- package/es/AeSdkBase.mjs +51 -3
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkMethods.d.ts +9 -14
- package/es/AeSdkMethods.mjs +20 -49
- package/es/AeSdkMethods.mjs.map +1 -1
- package/es/AeSdkWallet.d.ts +1 -1
- package/es/AeSdkWallet.mjs +79 -23
- package/es/AeSdkWallet.mjs.map +1 -1
- package/es/Middleware.d.ts +38 -0
- package/es/Middleware.mjs +90 -0
- package/es/Middleware.mjs.map +1 -0
- package/es/MiddlewareSubscriber.d.ts +30 -0
- package/es/MiddlewareSubscriber.mjs +198 -0
- package/es/MiddlewareSubscriber.mjs.map +1 -0
- package/es/Node.d.ts +1 -1
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +57 -3
- package/es/account/Base.mjs +95 -1
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Generalized.d.ts +4 -0
- package/es/account/Generalized.mjs +20 -0
- package/es/account/Generalized.mjs.map +1 -1
- package/es/account/Ledger.d.ts +4 -0
- package/es/account/Ledger.mjs +20 -0
- package/es/account/Ledger.mjs.map +1 -1
- package/es/account/LedgerFactory.mjs.map +1 -1
- package/es/account/Memory.d.ts +12 -0
- package/es/account/Memory.mjs +52 -0
- package/es/account/Memory.mjs.map +1 -1
- package/es/account/Rpc.d.ts +5 -6
- package/es/account/Rpc.mjs +53 -10
- package/es/account/Rpc.mjs.map +1 -1
- package/es/aens.d.ts +1 -1
- package/es/aens.mjs +1 -1
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -2
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/types.d.ts +19 -0
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
- package/es/aepp-wallet-communication/schema.d.ts +2 -8
- package/es/aepp-wallet-communication/schema.mjs +21 -33
- package/es/aepp-wallet-communication/schema.mjs.map +1 -1
- package/es/aepp-wallet-communication/wallet-detector.d.ts +1 -1
- package/es/aepp-wallet-communication/wallet-detector.mjs +0 -3
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
- package/es/apis/compiler/compiler.mjs +15 -1
- package/es/apis/compiler/compiler.mjs.map +1 -1
- package/es/apis/compiler/models/index.d.ts +1 -7
- package/es/apis/compiler/models/index.mjs.map +1 -1
- package/es/apis/compiler/models/mappers.d.ts +0 -1
- package/es/apis/compiler/models/mappers.mjs +0 -43
- package/es/apis/compiler/models/mappers.mjs.map +1 -1
- package/es/apis/middleware/index.d.ts +2 -0
- package/es/apis/middleware/index.mjs +3 -0
- package/es/apis/middleware/index.mjs.map +1 -0
- package/es/apis/middleware/middleware.d.ts +309 -0
- package/es/apis/middleware/middleware.mjs +1527 -0
- package/es/apis/middleware/middleware.mjs.map +1 -0
- package/es/apis/middleware/models/index.d.ts +1496 -0
- package/es/apis/middleware/models/index.mjs +580 -0
- package/es/apis/middleware/models/index.mjs.map +1 -0
- package/es/apis/middleware/models/mappers.d.ts +102 -0
- package/es/apis/middleware/models/mappers.mjs +3334 -0
- package/es/apis/middleware/models/mappers.mjs.map +1 -0
- package/es/apis/middleware/models/parameters.d.ts +43 -0
- package/es/apis/middleware/models/parameters.mjs +417 -0
- package/es/apis/middleware/models/parameters.mjs.map +1 -0
- package/es/apis/node/node.mjs.map +1 -1
- package/es/chain.d.ts +2 -1
- package/es/chain.mjs +5 -3
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +1 -1
- package/es/channel/Base.mjs +1 -4
- package/es/channel/Base.mjs.map +1 -1
- package/es/channel/Contract.mjs.map +1 -1
- package/es/channel/Spend.mjs.map +1 -1
- package/es/channel/handlers.mjs +2 -2
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.mjs +7 -5
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Contract.mjs +2 -2
- package/es/contract/Contract.mjs.map +1 -1
- package/es/contract/compiler/Base.d.ts +21 -0
- package/es/contract/compiler/Base.mjs.map +1 -1
- package/es/contract/compiler/Cli.d.ts +2 -0
- package/es/contract/compiler/Cli.mjs +24 -3
- package/es/contract/compiler/Cli.mjs.map +1 -1
- package/es/contract/compiler/Http.d.ts +2 -0
- package/es/contract/compiler/Http.mjs +22 -2
- package/es/contract/compiler/Http.mjs.map +1 -1
- package/es/contract/compiler/HttpNode.d.ts +1 -0
- package/es/contract/compiler/HttpNode.mjs +5 -0
- package/es/contract/compiler/HttpNode.mjs.map +1 -1
- package/es/contract/delegation-signature.d.ts +2 -1
- package/es/contract/delegation-signature.mjs +39 -8
- package/es/contract/delegation-signature.mjs.map +1 -1
- package/es/contract/ga.mjs.map +1 -1
- package/es/deprecated.d.ts +14 -0
- package/es/deprecated.mjs +22 -0
- package/es/deprecated.mjs.map +1 -0
- package/es/index-browser.d.ts +20 -14
- package/es/index-browser.mjs +19 -15
- package/es/index-browser.mjs.map +1 -1
- package/es/oracle.mjs.map +1 -1
- package/es/spend.d.ts +2 -1
- package/es/spend.mjs +4 -2
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/constants.d.ts +0 -1
- package/es/tx/builder/constants.mjs +26 -24
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/abi-version.mjs.map +1 -1
- package/es/tx/builder/field-types/coin-amount.d.ts +1 -1
- package/es/tx/builder/field-types/coin-amount.mjs +2 -1
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
- package/es/tx/builder/field-types/ct-version.mjs.map +1 -1
- package/es/tx/builder/field-types/deposit.d.ts +1 -1
- package/es/tx/builder/field-types/deposit.mjs.map +1 -1
- package/es/tx/builder/field-types/entry.mjs +2 -1
- package/es/tx/builder/field-types/entry.mjs.map +1 -1
- package/es/tx/builder/field-types/fee.mjs.map +1 -1
- package/es/tx/builder/field-types/field.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
- package/es/tx/builder/field-types/index.d.ts +28 -150
- package/es/tx/builder/field-types/index.mjs +28 -56
- package/es/tx/builder/field-types/index.mjs.map +1 -1
- package/es/tx/builder/field-types/map.mjs.map +1 -1
- package/es/tx/builder/field-types/mptree.mjs +3 -3
- package/es/tx/builder/field-types/mptree.mjs.map +1 -1
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
- package/es/tx/builder/field-types/pointers.mjs.map +1 -1
- package/es/tx/builder/field-types/string.mjs.map +1 -1
- package/es/tx/builder/field-types/ttl.mjs.map +1 -1
- package/es/tx/builder/field-types/u-int.mjs +1 -1
- package/es/tx/builder/field-types/u-int.mjs.map +1 -1
- package/es/tx/builder/helpers.d.ts +8 -1
- package/es/tx/builder/helpers.mjs +53 -9
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +4 -2
- package/es/tx/builder/index.mjs +0 -1
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +9 -9
- package/es/tx/builder/schema.mjs +11 -10
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/execution-cost.mjs.map +1 -1
- package/es/tx/transaction-signer.mjs.map +1 -1
- package/es/tx/validator.mjs +6 -3
- package/es/tx/validator.mjs.map +1 -1
- package/es/utils/amount-formatter.mjs +7 -7
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.mjs +6 -8
- package/es/utils/autorest.mjs.map +1 -1
- package/es/utils/bignumber.mjs.map +1 -1
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.d.ts +1 -0
- package/es/utils/crypto.mjs +12 -2
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/encoder-types.mjs +3 -3
- package/es/utils/encoder-types.mjs.map +1 -1
- package/es/utils/encoder.mjs.map +1 -1
- package/es/utils/errors.d.ts +2 -2
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/keystore.mjs.map +1 -1
- package/es/utils/other.d.ts +1 -0
- package/es/utils/other.mjs +5 -0
- package/es/utils/other.mjs.map +1 -1
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/es/utils/string.mjs.map +1 -1
- package/es/utils/typed-data.d.ts +45 -0
- package/es/utils/typed-data.mjs +70 -0
- package/es/utils/typed-data.mjs.map +1 -0
- package/package.json +56 -37
- package/src/AeSdkBase.ts +66 -5
- package/src/AeSdkMethods.ts +31 -50
- package/src/AeSdkWallet.ts +63 -17
- package/src/Middleware.ts +141 -0
- package/src/MiddlewareSubscriber.ts +207 -0
- package/src/Node.ts +1 -1
- package/src/account/Base.ts +102 -4
- package/src/account/Generalized.ts +20 -0
- package/src/account/Ledger.ts +20 -0
- package/src/account/Memory.ts +68 -1
- package/src/account/Rpc.ts +54 -7
- package/src/aens.ts +1 -1
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +11 -3
- package/src/aepp-wallet-communication/rpc/types.ts +21 -0
- package/src/aepp-wallet-communication/schema.ts +3 -17
- package/src/aepp-wallet-communication/wallet-detector.ts +1 -2
- package/src/apis/compiler/compiler.ts +8 -1
- package/src/apis/compiler/models/index.ts +1 -8
- package/src/apis/compiler/models/mappers.ts +0 -36
- package/src/apis/middleware/index.ts +2 -0
- package/src/apis/middleware/middleware.ts +1807 -0
- package/src/apis/middleware/models/index.ts +1747 -0
- package/src/apis/middleware/models/mappers.ts +3370 -0
- package/src/apis/middleware/models/parameters.ts +463 -0
- package/src/chain.ts +4 -3
- package/src/channel/Base.ts +5 -5
- package/src/channel/internal.ts +2 -0
- package/src/contract/Contract.ts +2 -1
- package/src/contract/compiler/Base.ts +26 -0
- package/src/contract/compiler/Cli.ts +27 -3
- package/src/contract/compiler/Http.ts +21 -2
- package/src/contract/compiler/HttpNode.ts +6 -0
- package/src/contract/delegation-signature.ts +37 -11
- package/src/deprecated.ts +23 -0
- package/src/index-browser.ts +77 -15
- package/src/spend.ts +2 -2
- package/src/tx/builder/constants.ts +0 -1
- package/src/tx/builder/field-types/coin-amount.ts +2 -1
- package/src/tx/builder/field-types/entry.ts +1 -1
- package/src/tx/builder/field-types/index.ts +28 -58
- package/src/tx/builder/field-types/u-int.ts +1 -1
- package/src/tx/builder/helpers.ts +54 -9
- package/src/tx/builder/index.ts +6 -9
- package/src/tx/validator.ts +4 -2
- package/src/utils/autorest.ts +5 -10
- package/src/utils/crypto.ts +12 -2
- package/src/utils/errors.ts +2 -2
- package/src/utils/other.ts +5 -0
- package/src/utils/typed-data.ts +95 -0
- package/types-legacy/ts4.2/AeSdkBase.d.ts +21 -3
- package/types-legacy/ts4.2/AeSdkMethods.d.ts +9 -14
- package/types-legacy/ts4.2/AeSdkWallet.d.ts +1 -1
- package/types-legacy/ts4.2/Middleware.d.ts +46 -0
- package/types-legacy/ts4.2/MiddlewareSubscriber.d.ts +30 -0
- package/types-legacy/ts4.2/Node.d.ts +1 -1
- package/types-legacy/ts4.2/account/Base.d.ts +57 -3
- package/types-legacy/ts4.2/account/Generalized.d.ts +4 -0
- package/types-legacy/ts4.2/account/Ledger.d.ts +4 -0
- package/types-legacy/ts4.2/account/Memory.d.ts +12 -0
- package/types-legacy/ts4.2/account/Rpc.d.ts +5 -6
- package/types-legacy/ts4.2/aens.d.ts +1 -1
- package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +19 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +2 -8
- package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +1 -1
- package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +1 -7
- package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +0 -1
- package/types-legacy/ts4.2/apis/middleware/index.d.ts +2 -0
- package/types-legacy/ts4.2/apis/middleware/middleware.d.ts +309 -0
- package/types-legacy/ts4.2/apis/middleware/models/index.d.ts +1496 -0
- package/types-legacy/ts4.2/apis/middleware/models/mappers.d.ts +102 -0
- package/types-legacy/ts4.2/apis/middleware/models/parameters.d.ts +43 -0
- package/types-legacy/ts4.2/chain.d.ts +2 -1
- package/types-legacy/ts4.2/channel/Base.d.ts +1 -1
- package/types-legacy/ts4.2/contract/compiler/Base.d.ts +21 -0
- package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +2 -0
- package/types-legacy/ts4.2/contract/compiler/Http.d.ts +2 -0
- package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +1 -0
- package/types-legacy/ts4.2/contract/delegation-signature.d.ts +2 -1
- package/types-legacy/ts4.2/deprecated.d.ts +14 -0
- package/types-legacy/ts4.2/index-browser.d.ts +20 -14
- package/types-legacy/ts4.2/spend.d.ts +2 -1
- package/types-legacy/ts4.2/tx/builder/constants.d.ts +0 -1
- package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +28 -153
- package/types-legacy/ts4.2/tx/builder/helpers.d.ts +8 -1
- package/types-legacy/ts4.2/tx/builder/index.d.ts +4 -2
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +9 -9
- package/types-legacy/ts4.2/utils/crypto.d.ts +1 -0
- package/types-legacy/ts4.2/utils/errors.d.ts +2 -2
- package/types-legacy/ts4.2/utils/other.d.ts +1 -0
- package/types-legacy/ts4.2/utils/typed-data.d.ts +60 -0
- package/types-legacy/ts4.5/AeSdkBase.d.ts +21 -3
- package/types-legacy/ts4.5/AeSdkMethods.d.ts +9 -14
- package/types-legacy/ts4.5/AeSdkWallet.d.ts +1 -1
- package/types-legacy/ts4.5/Middleware.d.ts +46 -0
- package/types-legacy/ts4.5/MiddlewareSubscriber.d.ts +30 -0
- package/types-legacy/ts4.5/Node.d.ts +1 -1
- package/types-legacy/ts4.5/account/Base.d.ts +57 -3
- package/types-legacy/ts4.5/account/Generalized.d.ts +4 -0
- package/types-legacy/ts4.5/account/Ledger.d.ts +4 -0
- package/types-legacy/ts4.5/account/Memory.d.ts +12 -0
- package/types-legacy/ts4.5/account/Rpc.d.ts +5 -6
- package/types-legacy/ts4.5/aens.d.ts +1 -1
- package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +19 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +2 -8
- package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +1 -1
- package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +1 -7
- package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +0 -1
- package/types-legacy/ts4.5/apis/middleware/index.d.ts +2 -0
- package/types-legacy/ts4.5/apis/middleware/middleware.d.ts +309 -0
- package/types-legacy/ts4.5/apis/middleware/models/index.d.ts +1496 -0
- package/types-legacy/ts4.5/apis/middleware/models/mappers.d.ts +102 -0
- package/types-legacy/ts4.5/apis/middleware/models/parameters.d.ts +43 -0
- package/types-legacy/ts4.5/chain.d.ts +2 -1
- package/types-legacy/ts4.5/channel/Base.d.ts +1 -1
- package/types-legacy/ts4.5/contract/compiler/Base.d.ts +21 -0
- package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +2 -0
- package/types-legacy/ts4.5/contract/compiler/Http.d.ts +2 -0
- package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +1 -0
- package/types-legacy/ts4.5/contract/delegation-signature.d.ts +2 -1
- package/types-legacy/ts4.5/deprecated.d.ts +14 -0
- package/types-legacy/ts4.5/index-browser.d.ts +20 -14
- package/types-legacy/ts4.5/spend.d.ts +2 -1
- package/types-legacy/ts4.5/tx/builder/constants.d.ts +0 -1
- package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +28 -153
- package/types-legacy/ts4.5/tx/builder/helpers.d.ts +8 -1
- package/types-legacy/ts4.5/tx/builder/index.d.ts +4 -2
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +9 -9
- package/types-legacy/ts4.5/utils/crypto.d.ts +1 -0
- package/types-legacy/ts4.5/utils/errors.d.ts +2 -2
- package/types-legacy/ts4.5/utils/other.d.ts +1 -0
- package/types-legacy/ts4.5/utils/typed-data.d.ts +60 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeternity/aepp-sdk",
|
|
3
|
-
"version": "13.0
|
|
3
|
+
"version": "13.2.0",
|
|
4
4
|
"description": "SDK for the æternity blockchain",
|
|
5
5
|
"main": "dist/aepp-sdk.js",
|
|
6
6
|
"types": "es/index.d.ts",
|
|
@@ -8,11 +8,17 @@
|
|
|
8
8
|
"<4.5": {
|
|
9
9
|
"es/index.d.ts": [
|
|
10
10
|
"./types-legacy/ts4.2/index.d.ts"
|
|
11
|
+
],
|
|
12
|
+
"es/index-browser.d.ts": [
|
|
13
|
+
"./types-legacy/ts4.2/index-browser.d.ts"
|
|
11
14
|
]
|
|
12
15
|
},
|
|
13
16
|
"<4.7": {
|
|
14
17
|
"es/index.d.ts": [
|
|
15
18
|
"./types-legacy/ts4.5/index.d.ts"
|
|
19
|
+
],
|
|
20
|
+
"es/index-browser.d.ts": [
|
|
21
|
+
"./types-legacy/ts4.5/index-browser.d.ts"
|
|
16
22
|
]
|
|
17
23
|
}
|
|
18
24
|
},
|
|
@@ -23,9 +29,15 @@
|
|
|
23
29
|
},
|
|
24
30
|
"exports": {
|
|
25
31
|
"node": {
|
|
32
|
+
"types@<4.5": "./types-legacy/ts4.2/index.d.ts",
|
|
33
|
+
"types@<4.7": "./types-legacy/ts4.5/index.d.ts",
|
|
34
|
+
"types": "./es/index.d.ts",
|
|
26
35
|
"import": "./es/index.mjs",
|
|
27
36
|
"default": "./dist/aepp-sdk.js"
|
|
28
37
|
},
|
|
38
|
+
"types@<4.5": "./types-legacy/ts4.2/index-browser.d.ts",
|
|
39
|
+
"types@<4.7": "./types-legacy/ts4.5/index-browser.d.ts",
|
|
40
|
+
"types": "./es/index-browser.d.ts",
|
|
29
41
|
"import": "./es/index-browser.mjs",
|
|
30
42
|
"default": "./dist/aepp-sdk.browser.js"
|
|
31
43
|
},
|
|
@@ -34,7 +46,10 @@
|
|
|
34
46
|
"build:assets": "node tooling/fetch-aesophia-cli.mjs",
|
|
35
47
|
"build:types": "tsc && node tooling/downlevel/run.mjs",
|
|
36
48
|
"build:es": "babel src --config-file ./babel.esm.config.js --out-dir es --extensions .js,.ts --out-file-extension .mjs --source-maps true",
|
|
37
|
-
"build:api": "
|
|
49
|
+
"build:api:node": "autorest tooling/autorest/node.yaml",
|
|
50
|
+
"build:api:compiler": "node tooling/autorest/compiler-prepare.mjs && autorest tooling/autorest/compiler.yaml",
|
|
51
|
+
"build:api:middleware": "node tooling/autorest/middleware-prepare.mjs && autorest tooling/autorest/middleware.yaml",
|
|
52
|
+
"build:api": "npm run build:api:node && npm run build:api:compiler && npm run build:api:middleware",
|
|
38
53
|
"build:generate": "ts-node --transpileOnly tooling/generate-schema.ts",
|
|
39
54
|
"build": "npm run build:api && npm run build:generate && webpack && npm run build:types && npm run build:es && npm run build:assets",
|
|
40
55
|
"docs:examples": "node tooling/docs/examples-to-md.js examples/node/*.mjs",
|
|
@@ -47,7 +62,7 @@
|
|
|
47
62
|
"test:unit": "mocha './test/unit/'",
|
|
48
63
|
"test:watch": "mocha './test/unit/' './test/integration/' --watch",
|
|
49
64
|
"prepare": "npm run build",
|
|
50
|
-
"prepublishOnly": "test/examples.sh
|
|
65
|
+
"prepublishOnly": "test/examples.sh",
|
|
51
66
|
"release": "standard-version --skip.tag --infile docs/CHANGELOG.md",
|
|
52
67
|
"release-alpha": "npm run release -- --prerelease alpha",
|
|
53
68
|
"release-beta": "npm run release -- --prerelease beta"
|
|
@@ -64,23 +79,26 @@
|
|
|
64
79
|
"@aeternity/argon2": "^0.0.1",
|
|
65
80
|
"@aeternity/uuid": "^0.0.1",
|
|
66
81
|
"@azure/core-client": "1.6.0",
|
|
67
|
-
"@azure/core-rest-pipeline": "^1.
|
|
68
|
-
"@babel/runtime-corejs3": "^7.
|
|
69
|
-
"@ledgerhq/hw-transport": "^6.28.
|
|
82
|
+
"@azure/core-rest-pipeline": "^1.11.0",
|
|
83
|
+
"@babel/runtime-corejs3": "^7.22.6",
|
|
84
|
+
"@ledgerhq/hw-transport": "^6.28.6",
|
|
70
85
|
"@types/aes-js": "^3.1.1",
|
|
71
86
|
"@types/json-bigint": "^1.0.1",
|
|
72
87
|
"@types/node": "~18.11.9",
|
|
73
|
-
"@types/sha.js": "^2.4.
|
|
74
|
-
"@types/uuid": "^9.0.
|
|
75
|
-
"@types/webextension-polyfill": "^0.10.
|
|
88
|
+
"@types/sha.js": "^2.4.1",
|
|
89
|
+
"@types/uuid": "^9.0.2",
|
|
90
|
+
"@types/webextension-polyfill": "^0.10.1",
|
|
76
91
|
"@types/websocket": "^1.0.5",
|
|
92
|
+
"@types/ws": "^8.5.5",
|
|
77
93
|
"aes-js": "^3.1.2",
|
|
78
94
|
"bignumber.js": "^9.1.1",
|
|
79
95
|
"bip32-path": "^0.4.2",
|
|
80
96
|
"blakejs": "^1.2.1",
|
|
81
97
|
"bs58": "^5.0.0",
|
|
82
98
|
"buffer": "^6.0.3",
|
|
99
|
+
"canonicalize": "^2.0.0",
|
|
83
100
|
"events": "^3.3.0",
|
|
101
|
+
"isomorphic-ws": "^5.0.0",
|
|
84
102
|
"json-bigint": "^1.0.0",
|
|
85
103
|
"process": "^0.11.10",
|
|
86
104
|
"rlp": "^3.0.0",
|
|
@@ -88,34 +106,35 @@
|
|
|
88
106
|
"tweetnacl": "^1.0.3",
|
|
89
107
|
"tweetnacl-auth": "^1.0.1",
|
|
90
108
|
"varuint-bitcoin": "^1.1.2",
|
|
91
|
-
"websocket": "^1.0.34"
|
|
109
|
+
"websocket": "^1.0.34",
|
|
110
|
+
"ws": "^8.13.0"
|
|
92
111
|
},
|
|
93
112
|
"repository": {
|
|
94
113
|
"type": "git",
|
|
95
114
|
"url": "https://github.com/aeternity/aepp-sdk-js"
|
|
96
115
|
},
|
|
97
116
|
"devDependencies": {
|
|
98
|
-
"@babel/cli": "^7.
|
|
99
|
-
"@babel/core": "^7.
|
|
100
|
-
"@babel/node": "^7.
|
|
101
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
102
|
-
"@babel/preset-env": "^7.
|
|
103
|
-
"@babel/preset-typescript": "^7.
|
|
104
|
-
"@babel/register": "^7.
|
|
105
|
-
"@commitlint/cli": "^17.
|
|
106
|
-
"@commitlint/config-conventional": "^17.
|
|
107
|
-
"@ledgerhq/hw-transport-mocker": "^6.27.
|
|
108
|
-
"@ledgerhq/hw-transport-node-hid-singleton": "^6.28.
|
|
109
|
-
"@ledgerhq/hw-transport-webusb": "^6.27.
|
|
110
|
-
"@types/chai": "^4.3.
|
|
117
|
+
"@babel/cli": "^7.22.9",
|
|
118
|
+
"@babel/core": "^7.22.9",
|
|
119
|
+
"@babel/node": "^7.22.6",
|
|
120
|
+
"@babel/plugin-transform-runtime": "^7.22.9",
|
|
121
|
+
"@babel/preset-env": "^7.22.9",
|
|
122
|
+
"@babel/preset-typescript": "^7.22.5",
|
|
123
|
+
"@babel/register": "^7.22.5",
|
|
124
|
+
"@commitlint/cli": "^17.6.7",
|
|
125
|
+
"@commitlint/config-conventional": "^17.6.7",
|
|
126
|
+
"@ledgerhq/hw-transport-mocker": "^6.27.17",
|
|
127
|
+
"@ledgerhq/hw-transport-node-hid-singleton": "^6.28.16",
|
|
128
|
+
"@ledgerhq/hw-transport-webusb": "^6.27.17",
|
|
129
|
+
"@types/chai": "^4.3.5",
|
|
111
130
|
"@types/chai-as-promised": "^7.1.5",
|
|
112
131
|
"@types/mocha": "^10.0.1",
|
|
113
132
|
"@types/node-hid": "^1.3.1",
|
|
114
|
-
"@types/sinon": "^10.0.
|
|
115
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
116
|
-
"@typescript-eslint/parser": "^
|
|
133
|
+
"@types/sinon": "^10.0.15",
|
|
134
|
+
"@typescript-eslint/eslint-plugin": "^6.2.0",
|
|
135
|
+
"@typescript-eslint/parser": "^6.2.0",
|
|
117
136
|
"autorest": "^3.6.3",
|
|
118
|
-
"babel-loader": "^9.1.
|
|
137
|
+
"babel-loader": "^9.1.3",
|
|
119
138
|
"babel-plugin-add-import-extension": "^1.6.0",
|
|
120
139
|
"babel-plugin-import-globals": "^2.0.0",
|
|
121
140
|
"babel-plugin-transform-default-named-imports": "^1.2.2",
|
|
@@ -123,24 +142,24 @@
|
|
|
123
142
|
"chai": "^4.3.7",
|
|
124
143
|
"chai-as-promised": "^7.1.1",
|
|
125
144
|
"downlevel-dts": "github:aeternity/downlevel-dts",
|
|
126
|
-
"eslint": "^8.
|
|
145
|
+
"eslint": "^8.45.0",
|
|
127
146
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
128
|
-
"eslint-config-airbnb-typescript": "^17.
|
|
147
|
+
"eslint-config-airbnb-typescript": "^17.1.0",
|
|
129
148
|
"eslint-plugin-rulesdir": "^0.2.2",
|
|
130
149
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
131
|
-
"html-webpack-plugin": "^5.5.
|
|
150
|
+
"html-webpack-plugin": "^5.5.3",
|
|
132
151
|
"mocha": "^10.2.0",
|
|
133
152
|
"nyc": "^15.1.0",
|
|
134
|
-
"sinon": "^15.0
|
|
153
|
+
"sinon": "^15.2.0",
|
|
135
154
|
"source-map": "^0.7.4",
|
|
136
155
|
"standard-version": "^9.5.0",
|
|
137
156
|
"ts-node": "^10.9.1",
|
|
138
|
-
"typedoc": "^0.
|
|
139
|
-
"typedoc-plugin-missing-exports": "^
|
|
140
|
-
"typescript": "^
|
|
141
|
-
"webpack": "^5.
|
|
142
|
-
"webpack-bundle-analyzer": "^4.
|
|
143
|
-
"webpack-cli": "^5.
|
|
157
|
+
"typedoc": "^0.24.8",
|
|
158
|
+
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
159
|
+
"typescript": "^5.1.6",
|
|
160
|
+
"webpack": "^5.88.2",
|
|
161
|
+
"webpack-bundle-analyzer": "^4.9.0",
|
|
162
|
+
"webpack-cli": "^5.1.4"
|
|
144
163
|
},
|
|
145
164
|
"files": [
|
|
146
165
|
"dist",
|
package/src/AeSdkBase.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import Node from './Node';
|
|
2
2
|
import AccountBase from './account/Base';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
CompilerError, DuplicateNodeError, NodeNotFoundError, NotImplementedError, TypeError,
|
|
5
|
+
} from './utils/errors';
|
|
4
6
|
import { Encoded } from './utils/encoder';
|
|
5
7
|
import CompilerBase from './contract/compiler/Base';
|
|
6
|
-
import AeSdkMethods, { OnAccount, getValueOrErrorProxy } from './AeSdkMethods';
|
|
8
|
+
import AeSdkMethods, { OnAccount, getValueOrErrorProxy, AeSdkMethodsOptions } from './AeSdkMethods';
|
|
9
|
+
import { AensName } from './tx/builder/constants';
|
|
7
10
|
|
|
8
11
|
type NodeInfo = Awaited<ReturnType<Node['getNodeInfo']>> & { name: string };
|
|
9
12
|
|
|
@@ -23,7 +26,7 @@ export default class AeSdkBase extends AeSdkMethods {
|
|
|
23
26
|
* @param options.nodes - Array of nodes
|
|
24
27
|
*/
|
|
25
28
|
constructor(
|
|
26
|
-
{ nodes = [], ...options }:
|
|
29
|
+
{ nodes = [], ...options }: AeSdkMethodsOptions & {
|
|
27
30
|
nodes?: Array<{ name: string; instance: Node }>;
|
|
28
31
|
} = {},
|
|
29
32
|
) {
|
|
@@ -127,6 +130,19 @@ export default class AeSdkBase extends AeSdkMethods {
|
|
|
127
130
|
return [];
|
|
128
131
|
}
|
|
129
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Resolves an account
|
|
135
|
+
* @param account - ak-address, instance of AccountBase, or keypair
|
|
136
|
+
*/
|
|
137
|
+
_resolveAccount(account: OnAccount = this._options.onAccount): AccountBase {
|
|
138
|
+
if (typeof account === 'string') throw new NotImplementedError('Address in AccountResolver');
|
|
139
|
+
if (typeof account === 'object') return account;
|
|
140
|
+
throw new TypeError(
|
|
141
|
+
'Account should be an address (ak-prefixed string), '
|
|
142
|
+
+ `or instance of AccountBase, got ${String(account)} instead`,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
130
146
|
get address(): Encoded.AccountAddress {
|
|
131
147
|
return this._resolveAccount().address;
|
|
132
148
|
}
|
|
@@ -153,15 +169,60 @@ export default class AeSdkBase extends AeSdkMethods {
|
|
|
153
169
|
return this._resolveAccount(onAccount).signMessage(message, options);
|
|
154
170
|
}
|
|
155
171
|
|
|
156
|
-
|
|
172
|
+
async signTypedData(
|
|
173
|
+
data: Encoded.ContractBytearray,
|
|
174
|
+
aci: Parameters<AccountBase['signTypedData']>[1],
|
|
175
|
+
{ onAccount, ...options }: { onAccount?: OnAccount } & Parameters<AccountBase['signTypedData']>[2] = {},
|
|
176
|
+
): Promise<Encoded.Signature> {
|
|
177
|
+
return this._resolveAccount(onAccount).signTypedData(data, aci, options);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async signDelegationToContract(
|
|
181
|
+
contractAddress: Encoded.ContractAddress,
|
|
182
|
+
{ onAccount, ...options }: { onAccount?: OnAccount }
|
|
183
|
+
& Parameters<AccountBase['signDelegationToContract']>[1] = {},
|
|
184
|
+
): Promise<Encoded.Signature> {
|
|
185
|
+
options.networkId ??= this.selectedNodeName !== null
|
|
186
|
+
? await this.api.getNetworkId() : undefined;
|
|
187
|
+
return this._resolveAccount(onAccount)
|
|
188
|
+
.signDelegationToContract(contractAddress, options);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async signNameDelegationToContract(
|
|
192
|
+
contractAddress: Encoded.ContractAddress,
|
|
193
|
+
name: AensName,
|
|
194
|
+
{ onAccount, ...options }: { onAccount?: OnAccount }
|
|
195
|
+
& Parameters<AccountBase['signNameDelegationToContract']>[2] = {},
|
|
196
|
+
): Promise<Encoded.Signature> {
|
|
197
|
+
options.networkId ??= this.selectedNodeName !== null
|
|
198
|
+
? await this.api.getNetworkId() : undefined;
|
|
199
|
+
return this._resolveAccount(onAccount)
|
|
200
|
+
.signNameDelegationToContract(contractAddress, name, options);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async signOracleQueryDelegationToContract(
|
|
204
|
+
contractAddress: Encoded.ContractAddress,
|
|
205
|
+
oracleQueryId: Encoded.OracleQueryId,
|
|
206
|
+
{ onAccount, ...options }: { onAccount?: OnAccount }
|
|
207
|
+
& Parameters<AccountBase['signOracleQueryDelegationToContract']>[2] = {},
|
|
208
|
+
): Promise<Encoded.Signature> {
|
|
209
|
+
options.networkId ??= this.selectedNodeName !== null
|
|
210
|
+
? await this.api.getNetworkId() : undefined;
|
|
211
|
+
return this._resolveAccount(onAccount)
|
|
212
|
+
.signOracleQueryDelegationToContract(contractAddress, oracleQueryId, options);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
override _getOptions(callOptions: AeSdkMethodsOptions = {}): {
|
|
157
216
|
onNode: Node;
|
|
158
217
|
onAccount: AccountBase;
|
|
159
218
|
onCompiler: CompilerBase;
|
|
160
219
|
} {
|
|
161
220
|
return {
|
|
162
|
-
...
|
|
221
|
+
...this._options,
|
|
163
222
|
onNode: getValueOrErrorProxy(() => this.api),
|
|
164
223
|
onCompiler: getValueOrErrorProxy(() => this.compilerApi),
|
|
224
|
+
...callOptions,
|
|
225
|
+
onAccount: getValueOrErrorProxy(() => this._resolveAccount(callOptions.onAccount)),
|
|
165
226
|
};
|
|
166
227
|
}
|
|
167
228
|
}
|
package/src/AeSdkMethods.ts
CHANGED
|
@@ -11,25 +11,27 @@ import Node from './Node';
|
|
|
11
11
|
import { TxParamsAsync } from './tx/builder/schema.generated';
|
|
12
12
|
import AccountBase from './account/Base';
|
|
13
13
|
import { Encoded } from './utils/encoder';
|
|
14
|
-
import
|
|
14
|
+
import CompilerBase from './contract/compiler/Base';
|
|
15
15
|
|
|
16
16
|
export type OnAccount = Encoded.AccountAddress | AccountBase | undefined;
|
|
17
17
|
|
|
18
|
-
export function getValueOrErrorProxy<Value extends object>(
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
export function getValueOrErrorProxy<Value extends object | undefined>(
|
|
19
|
+
valueCb: () => Value,
|
|
20
|
+
): NonNullable<Value> {
|
|
21
|
+
return new Proxy(
|
|
22
|
+
{},
|
|
23
|
+
Object.fromEntries(([
|
|
21
24
|
'apply', 'construct', 'defineProperty', 'deleteProperty', 'getOwnPropertyDescriptor',
|
|
22
25
|
'getPrototypeOf', 'isExtensible', 'ownKeys', 'preventExtensions', 'set', 'setPrototypeOf',
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const target = valueCb();
|
|
26
|
-
const
|
|
27
|
-
return typeof
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}) as Value;
|
|
26
|
+
'get', 'has',
|
|
27
|
+
] as const).map((name) => [name, (t: {}, ...args: unknown[]) => {
|
|
28
|
+
const target = valueCb() as object; // to get a native exception in case it missed
|
|
29
|
+
const res = (Reflect[name] as any)(target, ...args);
|
|
30
|
+
return typeof res === 'function' && name === 'get'
|
|
31
|
+
? res.bind(target) // otherwise it fails with attempted to get private field on non-instance
|
|
32
|
+
: res;
|
|
33
|
+
}])),
|
|
34
|
+
) as NonNullable<Value>;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
const { InvalidTxError: _2, ...chainMethodsOther } = chainMethods;
|
|
@@ -51,9 +53,8 @@ type GetMethodsOptions <Methods extends { [key: string]: Function }> =
|
|
|
51
53
|
? Args[Decrement<Args['length']>] : never
|
|
52
54
|
};
|
|
53
55
|
type MethodsOptions = GetMethodsOptions<typeof methods>;
|
|
54
|
-
interface AeSdkMethodsOptions
|
|
56
|
+
export interface AeSdkMethodsOptions
|
|
55
57
|
extends Partial<UnionToIntersection<MethodsOptions[keyof MethodsOptions]>> {
|
|
56
|
-
nodes?: Array<{ name: string; instance: Node }>;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
/**
|
|
@@ -79,24 +80,15 @@ class AeSdkMethods {
|
|
|
79
80
|
Object.assign(this._options, options);
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
*/
|
|
86
|
-
// eslint-disable-next-line class-methods-use-this
|
|
87
|
-
_resolveAccount(account?: OnAccount): AccountBase {
|
|
88
|
-
if (typeof account === 'string') throw new NotImplementedError('Address in AccountResolver');
|
|
89
|
-
if (typeof account === 'object') return account;
|
|
90
|
-
throw new TypeError(
|
|
91
|
-
'Account should be an address (ak-prefixed string), '
|
|
92
|
-
+ `or instance of AccountBase, got ${String(account)} instead`,
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
_getOptions(): AeSdkMethodsOptions & { onAccount: AccountBase } {
|
|
83
|
+
_getOptions(
|
|
84
|
+
callOptions: AeSdkMethodsOptions = {},
|
|
85
|
+
): AeSdkMethodsOptions & { onAccount: AccountBase; onCompiler: CompilerBase; onNode: Node } {
|
|
97
86
|
return {
|
|
98
87
|
...this._options,
|
|
99
|
-
onAccount: getValueOrErrorProxy(() => this.
|
|
88
|
+
onAccount: getValueOrErrorProxy(() => this._options.onAccount),
|
|
89
|
+
onNode: getValueOrErrorProxy(() => this._options.onNode),
|
|
90
|
+
onCompiler: getValueOrErrorProxy(() => this._options.onCompiler),
|
|
91
|
+
...callOptions,
|
|
100
92
|
};
|
|
101
93
|
}
|
|
102
94
|
|
|
@@ -107,16 +99,7 @@ class AeSdkMethods {
|
|
|
107
99
|
async initializeContract<Methods extends ContractMethodsBase>(
|
|
108
100
|
options?: Omit<Parameters<typeof Contract.initialize>[0], 'onNode'> & { onNode?: Node },
|
|
109
101
|
): Promise<Contract<Methods>> {
|
|
110
|
-
|
|
111
|
-
if (onCompiler == null || onNode == null) {
|
|
112
|
-
throw new ArgumentError('onCompiler, onNode', 'provided', null);
|
|
113
|
-
}
|
|
114
|
-
return Contract.initialize<Methods>({
|
|
115
|
-
...otherOptions,
|
|
116
|
-
onNode,
|
|
117
|
-
onCompiler,
|
|
118
|
-
...options,
|
|
119
|
-
});
|
|
102
|
+
return Contract.initialize<Methods>(this._getOptions(options as AeSdkMethodsOptions));
|
|
120
103
|
}
|
|
121
104
|
}
|
|
122
105
|
|
|
@@ -147,18 +130,16 @@ Object.assign(AeSdkMethods.prototype, mapObject<Function, Function>(
|
|
|
147
130
|
methods,
|
|
148
131
|
([name, handler]) => [
|
|
149
132
|
name,
|
|
150
|
-
function methodWrapper(...args: any[]) {
|
|
133
|
+
function methodWrapper(this: AeSdkMethods, ...args: any[]) {
|
|
151
134
|
args.length = handler.length;
|
|
152
135
|
const options = args[args.length - 1];
|
|
153
|
-
args[args.length - 1] =
|
|
154
|
-
...this._getOptions(),
|
|
155
|
-
...options,
|
|
156
|
-
...options?.onAccount != null && { onAccount: this._resolveAccount(options.onAccount) },
|
|
157
|
-
};
|
|
136
|
+
args[args.length - 1] = this._getOptions(options);
|
|
158
137
|
return handler(...args);
|
|
159
138
|
},
|
|
160
139
|
],
|
|
161
140
|
));
|
|
162
141
|
|
|
163
|
-
|
|
164
|
-
|
|
142
|
+
type AeSdkMethodsTyped = AeSdkMethods & AeSdkMethodsTransformed;
|
|
143
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
144
|
+
const AeSdkMethodsTyped = AeSdkMethods as new (options?: AeSdkMethodsOptions) => AeSdkMethodsTyped;
|
|
145
|
+
export default AeSdkMethodsTyped;
|
package/src/AeSdkWallet.ts
CHANGED
|
@@ -4,7 +4,7 @@ import verifyTransaction from './tx/validator';
|
|
|
4
4
|
import RpcClient from './aepp-wallet-communication/rpc/RpcClient';
|
|
5
5
|
import {
|
|
6
6
|
METHODS, RPC_STATUS, SUBSCRIPTION_TYPES, WALLET_TYPE,
|
|
7
|
-
|
|
7
|
+
RpcInvalidTransactionError,
|
|
8
8
|
RpcNotAuthorizeError, RpcPermissionDenyError, RpcUnsupportedProtocolError,
|
|
9
9
|
} from './aepp-wallet-communication/schema';
|
|
10
10
|
import { InternalError, UnknownRpcClientError } from './utils/errors';
|
|
@@ -106,12 +106,23 @@ export default class AeSdkWallet extends AeSdk {
|
|
|
106
106
|
this._type = type;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
_getAccountsForClient({ addressSubscription }: RpcClientsInfo): Accounts {
|
|
110
|
+
const { current, connected } = this.getAccounts();
|
|
111
|
+
return {
|
|
112
|
+
current: addressSubscription.has('current') || addressSubscription.has('connected')
|
|
113
|
+
? current : {},
|
|
114
|
+
connected: addressSubscription.has('connected') ? connected : {},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
109
118
|
_pushAccountsToApps(): void {
|
|
110
119
|
if (this._clients == null) return;
|
|
111
120
|
Array.from(this._clients.keys())
|
|
112
|
-
.filter((clientId) => this.
|
|
113
|
-
.map((clientId) => this._getClient(clientId)
|
|
114
|
-
.
|
|
121
|
+
.filter((clientId) => this._isRpcClientConnected(clientId))
|
|
122
|
+
.map((clientId) => this._getClient(clientId))
|
|
123
|
+
.filter((client) => client.addressSubscription.size !== 0)
|
|
124
|
+
.forEach((client) => client.rpc
|
|
125
|
+
.notify(METHODS.updateAddress, this._getAccountsForClient(client)));
|
|
115
126
|
}
|
|
116
127
|
|
|
117
128
|
override selectAccount(address: Encoded.AccountAddress): void {
|
|
@@ -149,11 +160,6 @@ export default class AeSdkWallet extends AeSdk {
|
|
|
149
160
|
return client;
|
|
150
161
|
}
|
|
151
162
|
|
|
152
|
-
_isRpcClientSubscribed(clientId: string): boolean {
|
|
153
|
-
return this._isRpcClientConnected(clientId)
|
|
154
|
-
&& this._getClient(clientId).addressSubscription.size !== 0;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
163
|
_isRpcClientConnected(clientId: string): boolean {
|
|
158
164
|
return RPC_STATUS.CONNECTED === this._getClient(clientId).status
|
|
159
165
|
&& this._getClient(clientId).rpc.connection.isConnected();
|
|
@@ -219,10 +225,10 @@ export default class AeSdkWallet extends AeSdk {
|
|
|
219
225
|
[METHODS.subscribeAddress]: async ({ type, value }, origin) => {
|
|
220
226
|
if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
|
|
221
227
|
|
|
222
|
-
await this.onSubscription(id, { type, value }, origin);
|
|
223
|
-
|
|
224
228
|
switch (type) {
|
|
225
229
|
case SUBSCRIPTION_TYPES.subscribe:
|
|
230
|
+
// TODO: remove `type` as it always subscribe
|
|
231
|
+
await this.onSubscription(id, { type, value }, origin);
|
|
226
232
|
client.addressSubscription.add(value);
|
|
227
233
|
break;
|
|
228
234
|
case SUBSCRIPTION_TYPES.unsubscribe:
|
|
@@ -234,22 +240,29 @@ export default class AeSdkWallet extends AeSdk {
|
|
|
234
240
|
|
|
235
241
|
return {
|
|
236
242
|
subscription: Array.from(client.addressSubscription),
|
|
237
|
-
address: this.
|
|
243
|
+
address: this._getAccountsForClient(client),
|
|
238
244
|
};
|
|
239
245
|
},
|
|
240
246
|
[METHODS.address]: async (params, origin) => {
|
|
241
|
-
if (!this.
|
|
247
|
+
if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
|
|
242
248
|
await this.onAskAccounts(id, params, origin);
|
|
243
249
|
return this.addresses();
|
|
244
250
|
},
|
|
245
|
-
[METHODS.sign]: async (
|
|
251
|
+
[METHODS.sign]: async (
|
|
252
|
+
{
|
|
253
|
+
tx, onAccount = this.address, returnSigned, innerTx,
|
|
254
|
+
},
|
|
255
|
+
origin,
|
|
256
|
+
) => {
|
|
246
257
|
if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
|
|
247
258
|
if (!this.addresses().includes(onAccount)) {
|
|
248
259
|
throw new RpcPermissionDenyError(onAccount);
|
|
249
260
|
}
|
|
250
261
|
|
|
251
|
-
const parameters = {
|
|
252
|
-
|
|
262
|
+
const parameters = {
|
|
263
|
+
onAccount, aeppOrigin: origin, aeppRpcClientId: id, innerTx,
|
|
264
|
+
};
|
|
265
|
+
if (returnSigned || innerTx === true) {
|
|
253
266
|
return { signedTransaction: await this.signTransaction(tx, parameters) };
|
|
254
267
|
}
|
|
255
268
|
try {
|
|
@@ -259,7 +272,7 @@ export default class AeSdkWallet extends AeSdk {
|
|
|
259
272
|
} catch (error) {
|
|
260
273
|
const validation = await verifyTransaction(tx, this.api);
|
|
261
274
|
if (validation.length > 0) throw new RpcInvalidTransactionError(validation);
|
|
262
|
-
throw
|
|
275
|
+
throw error;
|
|
263
276
|
}
|
|
264
277
|
},
|
|
265
278
|
[METHODS.signMessage]: async ({ message, onAccount = this.address }, origin) => {
|
|
@@ -273,6 +286,39 @@ export default class AeSdkWallet extends AeSdk {
|
|
|
273
286
|
signature: Buffer.from(await this.signMessage(message, parameters)).toString('hex'),
|
|
274
287
|
};
|
|
275
288
|
},
|
|
289
|
+
[METHODS.signTypedData]: async ({
|
|
290
|
+
domain, aci, data, onAccount = this.address,
|
|
291
|
+
}, origin) => {
|
|
292
|
+
if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
|
|
293
|
+
if (!this.addresses().includes(onAccount)) {
|
|
294
|
+
throw new RpcPermissionDenyError(onAccount);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const parameters = {
|
|
298
|
+
...domain, onAccount, aeppOrigin: origin, aeppRpcClientId: id,
|
|
299
|
+
};
|
|
300
|
+
return {
|
|
301
|
+
signature: await this.signTypedData(data, aci, parameters),
|
|
302
|
+
};
|
|
303
|
+
},
|
|
304
|
+
[METHODS.signDelegationToContract]: async ({
|
|
305
|
+
contractAddress, name, oracleQueryId, onAccount = this.address,
|
|
306
|
+
}, origin) => {
|
|
307
|
+
if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
|
|
308
|
+
if (!this.addresses().includes(onAccount)) {
|
|
309
|
+
throw new RpcPermissionDenyError(onAccount);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const parameters = { onAccount, aeppOrigin: origin, aeppRpcClientId: id };
|
|
313
|
+
const signature = await (
|
|
314
|
+
(name == null ? null : this
|
|
315
|
+
.signNameDelegationToContract(contractAddress, name, parameters))
|
|
316
|
+
?? (oracleQueryId == null ? null : this
|
|
317
|
+
.signOracleQueryDelegationToContract(contractAddress, oracleQueryId, parameters))
|
|
318
|
+
?? this.signDelegationToContract(contractAddress, parameters)
|
|
319
|
+
);
|
|
320
|
+
return { signature };
|
|
321
|
+
},
|
|
276
322
|
},
|
|
277
323
|
),
|
|
278
324
|
};
|