@aeternity/aepp-sdk 12.0.0 → 12.1.2
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 +20765 -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 +36 -34
- 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 +172 -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/Node.ts
CHANGED
|
@@ -1,40 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
// eslint-disable-next-line max-classes-per-file
|
|
2
|
+
import BigNumber from 'bignumber.js';
|
|
3
|
+
import { OperationArguments, OperationSpec } from '@azure/core-client';
|
|
3
4
|
import {
|
|
4
5
|
genRequestQueuesPolicy, genCombineGetRequestsPolicy, genErrorFormatterPolicy,
|
|
5
|
-
genVersionCheckPolicy
|
|
6
|
-
} from './utils/autorest'
|
|
7
|
-
import { Node as NodeApi, NodeOptionalParams, ErrorModel } from './apis/node
|
|
8
|
-
import { mapObject } from './utils/other'
|
|
9
|
-
import {
|
|
10
|
-
import { MissingParamError } from './utils/errors'
|
|
6
|
+
genVersionCheckPolicy,
|
|
7
|
+
} from './utils/autorest';
|
|
8
|
+
import { Node as NodeApi, NodeOptionalParams, ErrorModel } from './apis/node';
|
|
9
|
+
import { mapObject } from './utils/other';
|
|
10
|
+
import { Encoded } from './utils/encoder';
|
|
11
|
+
import { MissingParamError } from './utils/errors';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Obtain networkId from account or node
|
|
14
15
|
*/
|
|
15
|
-
export async function getNetworkId
|
|
16
|
-
const res = networkId ?? this.networkId ?? (await this.api?.getStatus())
|
|
17
|
-
if (res != null) return res
|
|
18
|
-
throw new MissingParamError('networkId is not provided')
|
|
16
|
+
export async function getNetworkId({ networkId }: { networkId?: string } = {}): Promise<string> {
|
|
17
|
+
const res = networkId ?? this.networkId ?? (await this.api?.getStatus())?.networkId;
|
|
18
|
+
if (res != null) return res;
|
|
19
|
+
throw new MissingParamError('networkId is not provided');
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const bigIntPropertyNames = [
|
|
22
23
|
'balance', 'queryFee', 'fee', 'amount', 'nameFee', 'channelAmount',
|
|
23
24
|
'initiatorAmount', 'responderAmount', 'channelReserve', 'initiatorAmountFinal',
|
|
24
|
-
'responderAmountFinal', 'gasPrice', 'deposit'
|
|
25
|
-
] as const
|
|
25
|
+
'responderAmountFinal', 'gasPrice', 'deposit',
|
|
26
|
+
] as const;
|
|
26
27
|
|
|
27
28
|
const numberPropertyNames = [
|
|
28
29
|
'time', 'gas', 'gasUsed', 'nameSalt',
|
|
29
|
-
'nonce', 'nextNonce', 'height', 'blockHeight', 'top', 'topBlockHeight',
|
|
30
|
+
'nonce', 'nextNonce', 'height', 'blockHeight', 'top', 'topBlockHeight',
|
|
31
|
+
'ttl', 'nameTtl', 'clientTtl',
|
|
30
32
|
'inbound', 'outbound', 'peerCount', 'pendingTransactionsCount', 'effectiveAtHeight',
|
|
31
|
-
'version', 'solutions'
|
|
32
|
-
] as const
|
|
33
|
+
'version', 'solutions', 'round',
|
|
34
|
+
] as const;
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
class NodeTransformed extends NodeApi {
|
|
37
|
+
async sendOperationRequest(
|
|
38
|
+
operationArguments: OperationArguments,
|
|
39
|
+
operationSpec: OperationSpec,
|
|
40
|
+
): Promise<any> {
|
|
41
|
+
const args = mapObject(
|
|
42
|
+
operationArguments,
|
|
43
|
+
([key, value]) => [key, this.#encodeArg(value)],
|
|
44
|
+
) as OperationArguments;
|
|
45
|
+
return this.#decodeRes(await super.sendOperationRequest(args, operationSpec));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#mapData(data: any, transform: {
|
|
49
|
+
bigInt: (v: any) => any;
|
|
50
|
+
number: (v: any) => any;
|
|
51
|
+
}): unknown {
|
|
52
|
+
if (Array.isArray(data)) return data.map((d) => this.#mapData(d, transform));
|
|
53
|
+
if (data != null && typeof data === 'object') {
|
|
54
|
+
return mapObject(data, ([key, value]) => {
|
|
55
|
+
if (value == null) return [key, value];
|
|
56
|
+
if (bigIntPropertyNames.some((k) => k === key)) return [key, transform.bigInt(value)];
|
|
57
|
+
if (numberPropertyNames.some((k) => k === key)) return [key, transform.number(value)];
|
|
58
|
+
return [key, this.#mapData(value, transform)];
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
#encodeArg(data: any): any {
|
|
65
|
+
return this.#mapData(data, {
|
|
66
|
+
bigInt: (value) => {
|
|
67
|
+
if (value instanceof BigNumber) return value.toFixed();
|
|
68
|
+
return value.toString();
|
|
69
|
+
},
|
|
70
|
+
number: (value) => value.toString(),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
#decodeRes(data: any): any {
|
|
75
|
+
return this.#mapData(data, {
|
|
76
|
+
bigInt: (value) => BigInt(value),
|
|
77
|
+
number: (value) => +value,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
type BigIntPropertyNames = typeof bigIntPropertyNames[number];
|
|
83
|
+
type NumberPropertyNames = typeof numberPropertyNames[number];
|
|
36
84
|
type PreserveOptional<NewType, OrigType> =
|
|
37
|
-
OrigType extends undefined ? NewType | undefined : NewType
|
|
85
|
+
OrigType extends undefined ? NewType | undefined : NewType;
|
|
38
86
|
export type TransformNodeType<Type> =
|
|
39
87
|
Type extends (...args: infer Args) => infer Ret
|
|
40
88
|
? (...args: TransformNodeType<Args>) => TransformNodeType<Ret>
|
|
@@ -46,38 +94,40 @@ export type TransformNodeType<Type> =
|
|
|
46
94
|
? Promise<TransformNodeType<T>>
|
|
47
95
|
: Type extends { [P in any]: any }
|
|
48
96
|
? {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
: Type
|
|
59
|
-
type
|
|
60
|
-
[Name in keyof InstanceType<typeof NodeApi>]:
|
|
61
|
-
|
|
97
|
+
[Property in keyof Type]:
|
|
98
|
+
Property extends BigIntPropertyNames
|
|
99
|
+
? PreserveOptional<bigint, Type[Property]>
|
|
100
|
+
: Property extends NumberPropertyNames
|
|
101
|
+
? PreserveOptional<number, Type[Property]>
|
|
102
|
+
: Property extends 'txHash'
|
|
103
|
+
? PreserveOptional<Encoded.TxHash, Type[Property]>
|
|
104
|
+
: TransformNodeType<Type[Property]>
|
|
105
|
+
}
|
|
106
|
+
: Type;
|
|
107
|
+
type NodeTransformedApi = new (...args: ConstructorParameters<typeof NodeApi>) => {
|
|
108
|
+
[Name in keyof InstanceType<typeof NodeApi>]:
|
|
109
|
+
Name extends 'pipeline' | 'sendRequest' | 'sendOperationRequest'
|
|
110
|
+
? NodeApi[Name] : TransformNodeType<NodeApi[Name]>
|
|
111
|
+
};
|
|
62
112
|
|
|
63
113
|
export interface NodeInfo {
|
|
64
|
-
url: string
|
|
65
|
-
nodeNetworkId: string
|
|
66
|
-
version: string
|
|
67
|
-
consensusProtocolVersion: number
|
|
114
|
+
url: string;
|
|
115
|
+
nodeNetworkId: string;
|
|
116
|
+
version: string;
|
|
117
|
+
consensusProtocolVersion: number;
|
|
68
118
|
}
|
|
69
119
|
|
|
70
|
-
export default class Node extends (
|
|
71
|
-
url: string
|
|
120
|
+
export default class Node extends (NodeTransformed as unknown as NodeTransformedApi) {
|
|
121
|
+
url: string;
|
|
72
122
|
|
|
73
123
|
/**
|
|
74
124
|
* @param url - Url for node API
|
|
75
125
|
* @param options - Options
|
|
76
126
|
* @param options.ignoreVersion - Don't check node version
|
|
77
127
|
*/
|
|
78
|
-
constructor
|
|
128
|
+
constructor(
|
|
79
129
|
url: string,
|
|
80
|
-
{ ignoreVersion = false, ...options }: NodeOptionalParams & { ignoreVersion?: boolean } = {}
|
|
130
|
+
{ ignoreVersion = false, ...options }: NodeOptionalParams & { ignoreVersion?: boolean } = {},
|
|
81
131
|
) {
|
|
82
132
|
// eslint-disable-next-line constructor-super
|
|
83
133
|
super(url, {
|
|
@@ -85,83 +135,39 @@ export default class Node extends (NodeApi as unknown as TransformedNode) {
|
|
|
85
135
|
additionalPolicies: [
|
|
86
136
|
genRequestQueuesPolicy(),
|
|
87
137
|
genCombineGetRequestsPolicy(),
|
|
88
|
-
genErrorFormatterPolicy((body: ErrorModel) => ` ${body.reason}`)
|
|
138
|
+
genErrorFormatterPolicy((body: ErrorModel) => ` ${body.reason}`),
|
|
89
139
|
],
|
|
90
|
-
...options
|
|
91
|
-
})
|
|
92
|
-
this.url = url
|
|
140
|
+
...options,
|
|
141
|
+
});
|
|
142
|
+
this.url = url;
|
|
93
143
|
if (!ignoreVersion) {
|
|
94
|
-
const versionPromise = this.getStatus().then(({ nodeVersion }) => nodeVersion)
|
|
95
|
-
this.pipeline.addPolicy(
|
|
144
|
+
const versionPromise = this.getStatus().then(({ nodeVersion }) => nodeVersion);
|
|
145
|
+
this.pipeline.addPolicy(
|
|
146
|
+
genVersionCheckPolicy('node', '/v3/status', versionPromise, '6.2.0', '7.0.0'),
|
|
147
|
+
);
|
|
96
148
|
}
|
|
97
|
-
this.intAsString = true
|
|
149
|
+
this.intAsString = true;
|
|
98
150
|
}
|
|
99
151
|
|
|
100
|
-
async getNodeInfo
|
|
152
|
+
async getNodeInfo(): Promise<NodeInfo> {
|
|
101
153
|
const {
|
|
102
154
|
nodeVersion: version,
|
|
103
155
|
networkId: nodeNetworkId,
|
|
104
156
|
protocols,
|
|
105
|
-
topBlockHeight
|
|
106
|
-
} = await this.getStatus()
|
|
157
|
+
topBlockHeight,
|
|
158
|
+
} = await this.getStatus();
|
|
107
159
|
const consensusProtocolVersion = protocols
|
|
108
160
|
.filter(({ effectiveAtHeight }) => topBlockHeight >= effectiveAtHeight)
|
|
109
161
|
.reduce(
|
|
110
|
-
(acc, p) => p.effectiveAtHeight > acc.effectiveAtHeight ? p : acc,
|
|
111
|
-
{ effectiveAtHeight: -1, version: 0 }
|
|
162
|
+
(acc, p) => (p.effectiveAtHeight > acc.effectiveAtHeight ? p : acc),
|
|
163
|
+
{ effectiveAtHeight: -1, version: 0 },
|
|
112
164
|
)
|
|
113
|
-
.version
|
|
165
|
+
.version;
|
|
114
166
|
return {
|
|
115
167
|
url: this.url,
|
|
116
168
|
nodeNetworkId,
|
|
117
169
|
version,
|
|
118
|
-
consensusProtocolVersion
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/27689
|
|
123
|
-
async sendOperationRequest (
|
|
124
|
-
operationArguments: OperationArguments, operationSpec: OperationSpec
|
|
125
|
-
): Promise<any> {
|
|
126
|
-
const args = mapObject(
|
|
127
|
-
operationArguments,
|
|
128
|
-
([key, value]) => [key, this.#encodeArg(value)]
|
|
129
|
-
) as OperationArguments
|
|
130
|
-
return this.#decodeRes(await super.sendOperationRequest(args, operationSpec))
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
#mapData (
|
|
134
|
-
data: any, transform: {
|
|
135
|
-
bigInt: (v: any) => any
|
|
136
|
-
number: (v: any) => any
|
|
137
|
-
}
|
|
138
|
-
): unknown {
|
|
139
|
-
if (Array.isArray(data)) return data.map(d => this.#mapData(d, transform))
|
|
140
|
-
if (data != null && typeof data === 'object') {
|
|
141
|
-
return mapObject(data, ([key, value]) => {
|
|
142
|
-
if (value == null) return [key, value]
|
|
143
|
-
if (bigIntPropertyNames.some(k => k === key)) return [key, transform.bigInt(value)]
|
|
144
|
-
if (numberPropertyNames.some(k => k === key)) return [key, transform.number(value)]
|
|
145
|
-
return [key, this.#mapData(value, transform)]
|
|
146
|
-
})
|
|
147
|
-
}
|
|
148
|
-
return data
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
#encodeArg (data: any): any {
|
|
152
|
-
return this.#mapData(data, {
|
|
153
|
-
bigInt: value => {
|
|
154
|
-
if (value instanceof BigNumber) return value.toFixed()
|
|
155
|
-
return value.toString()
|
|
156
|
-
},
|
|
157
|
-
number: value => value.toString()
|
|
158
|
-
})
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
#decodeRes (data: any): any {
|
|
162
|
-
return this.#mapData(data, {
|
|
163
|
-
bigInt: value => BigInt(value),
|
|
164
|
-
number: value => +value
|
|
165
|
-
})
|
|
170
|
+
consensusProtocolVersion,
|
|
171
|
+
};
|
|
166
172
|
}
|
|
167
173
|
}
|
package/src/account/Base.ts
CHANGED
|
@@ -14,33 +14,35 @@
|
|
|
14
14
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
15
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
16
|
*/
|
|
17
|
-
import { messageToHash, verifyMessage as verifyMessageCrypto, hash } from '../utils/crypto'
|
|
18
|
-
import { buildTx } from '../tx/builder'
|
|
19
|
-
import { decode,
|
|
20
|
-
import {
|
|
21
|
-
import { getNetworkId } from '../Node'
|
|
22
|
-
import { concatBuffers } from '../utils/other'
|
|
17
|
+
import { messageToHash, verifyMessage as verifyMessageCrypto, hash } from '../utils/crypto';
|
|
18
|
+
import { buildTx } from '../tx/builder';
|
|
19
|
+
import { decode, Encoded } from '../utils/encoder';
|
|
20
|
+
import { Tag } from '../tx/builder/constants';
|
|
21
|
+
import { getNetworkId } from '../Node';
|
|
22
|
+
import { concatBuffers } from '../utils/other';
|
|
23
|
+
import type { createMetaTx } from '../contract/ga';
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Check is provided object looks like an instance of AccountBase
|
|
26
27
|
* @param acc - Object to check
|
|
27
28
|
*/
|
|
28
|
-
export const isAccountBase = (acc: AccountBase | any): boolean =>
|
|
29
|
-
!['sign', 'address', 'signTransaction', 'signMessage'].some(f => typeof acc[f] !== 'function')
|
|
29
|
+
export const isAccountBase = (acc: AccountBase | any): boolean => (
|
|
30
|
+
!['sign', 'address', 'signTransaction', 'signMessage'].some((f) => typeof acc[f] !== 'function')
|
|
31
|
+
);
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
34
|
* Account is one of the three basic building blocks of an
|
|
33
35
|
* {@link AeSdk} and provides access to a signing key pair.
|
|
34
36
|
*/
|
|
35
37
|
export default abstract class AccountBase {
|
|
36
|
-
networkId?: string
|
|
38
|
+
networkId?: string;
|
|
37
39
|
|
|
38
40
|
/**
|
|
39
41
|
* @param options - Options
|
|
40
42
|
* @param options.networkId - Using for signing transactions
|
|
41
43
|
*/
|
|
42
|
-
constructor
|
|
43
|
-
this.networkId ??= networkId
|
|
44
|
+
constructor({ networkId }: { networkId?: string } = {}) {
|
|
45
|
+
this.networkId ??= networkId;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
/**
|
|
@@ -50,24 +52,29 @@ export default abstract class AccountBase {
|
|
|
50
52
|
* @param opt.innerTx - Sign as inner transaction for PayingFor
|
|
51
53
|
* @returns Signed transaction
|
|
52
54
|
*/
|
|
53
|
-
async signTransaction
|
|
54
|
-
tx:
|
|
55
|
-
{ innerTx, networkId, ...options }: {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
async signTransaction(
|
|
56
|
+
tx: Encoded.Transaction,
|
|
57
|
+
{ innerTx, networkId, ...options }: {
|
|
58
|
+
innerTx?: boolean;
|
|
59
|
+
networkId?: string;
|
|
60
|
+
authData?: Parameters<typeof createMetaTx>[1];
|
|
61
|
+
authFun?: Parameters<typeof createMetaTx>[2];
|
|
62
|
+
} & Omit<Partial<Parameters<typeof createMetaTx>[3]>, 'onAccount'> = {},
|
|
63
|
+
): Promise<Encoded.Transaction> {
|
|
64
|
+
const prefixes = [await this.getNetworkId({ networkId })];
|
|
65
|
+
if (innerTx === true) prefixes.push('inner_tx');
|
|
66
|
+
const rlpBinaryTx = decode(tx);
|
|
67
|
+
const txWithNetworkId = concatBuffers([Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)]);
|
|
61
68
|
|
|
62
|
-
const signatures = [await this.sign(txWithNetworkId, options)]
|
|
63
|
-
return buildTx({ encodedTx: rlpBinaryTx, signatures },
|
|
69
|
+
const signatures = [await this.sign(txWithNetworkId, options)];
|
|
70
|
+
return buildTx({ encodedTx: rlpBinaryTx, signatures }, Tag.SignedTx).tx;
|
|
64
71
|
}
|
|
65
72
|
|
|
66
73
|
/**
|
|
67
74
|
* Get network Id
|
|
68
75
|
* @returns Network Id
|
|
69
76
|
*/
|
|
70
|
-
readonly getNetworkId = getNetworkId
|
|
77
|
+
readonly getNetworkId = getNetworkId;
|
|
71
78
|
|
|
72
79
|
/**
|
|
73
80
|
* Sign message
|
|
@@ -75,11 +82,12 @@ export default abstract class AccountBase {
|
|
|
75
82
|
* @param opt - Options
|
|
76
83
|
* @returns Signature as hex string of Uint8Array
|
|
77
84
|
*/
|
|
78
|
-
async signMessage
|
|
79
|
-
message: string,
|
|
85
|
+
async signMessage(
|
|
86
|
+
message: string,
|
|
87
|
+
{ returnHex = false, ...options }: { returnHex?: boolean } = {},
|
|
80
88
|
): Promise<string | Uint8Array> {
|
|
81
|
-
const sig = await this.sign(messageToHash(message), options)
|
|
82
|
-
return returnHex ? Buffer.from(sig).toString('hex') : sig
|
|
89
|
+
const sig = await this.sign(messageToHash(message), options);
|
|
90
|
+
return returnHex ? Buffer.from(sig).toString('hex') : sig;
|
|
83
91
|
}
|
|
84
92
|
|
|
85
93
|
/**
|
|
@@ -88,14 +96,16 @@ export default abstract class AccountBase {
|
|
|
88
96
|
* @param signature - Signature
|
|
89
97
|
* @param options - Options
|
|
90
98
|
*/
|
|
91
|
-
async verifyMessage
|
|
92
|
-
message: string,
|
|
99
|
+
async verifyMessage(
|
|
100
|
+
message: string,
|
|
101
|
+
signature: string | Uint8Array,
|
|
102
|
+
options?: object,
|
|
93
103
|
): Promise<boolean> {
|
|
94
104
|
return verifyMessageCrypto(
|
|
95
105
|
message,
|
|
96
106
|
typeof signature === 'string' ? Buffer.from(signature, 'hex') : signature,
|
|
97
|
-
decode(await this.address(options))
|
|
98
|
-
)
|
|
107
|
+
decode(await this.address(options)),
|
|
108
|
+
);
|
|
99
109
|
}
|
|
100
110
|
|
|
101
111
|
/**
|
|
@@ -104,11 +114,11 @@ export default abstract class AccountBase {
|
|
|
104
114
|
* @param options - Options
|
|
105
115
|
* @returns Signed data blob
|
|
106
116
|
*/
|
|
107
|
-
abstract sign
|
|
117
|
+
abstract sign(data: string | Uint8Array, options?: any): Promise<Uint8Array>;
|
|
108
118
|
|
|
109
119
|
/**
|
|
110
120
|
* Obtain account address
|
|
111
121
|
* @returns Public account address
|
|
112
122
|
*/
|
|
113
|
-
abstract address
|
|
123
|
+
abstract address(opt?: object): Promise<Encoded.AccountAddress>;
|
|
114
124
|
}
|
package/src/account/Memory.ts
CHANGED
|
@@ -14,25 +14,25 @@
|
|
|
14
14
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
15
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
16
|
*/
|
|
17
|
-
import AccountBase from './Base'
|
|
18
|
-
import { sign, isValidKeypair } from '../utils/crypto'
|
|
19
|
-
import { isHex } from '../utils/string'
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
17
|
+
import AccountBase from './Base';
|
|
18
|
+
import { sign, isValidKeypair } from '../utils/crypto';
|
|
19
|
+
import { isHex } from '../utils/string';
|
|
20
|
+
import { ArgumentError, InvalidKeypairError, MissingParamError } from '../utils/errors';
|
|
21
|
+
import { decode, Encoded } from '../utils/encoder';
|
|
22
|
+
import { createMetaTx } from '../contract/ga';
|
|
23
23
|
|
|
24
|
-
const secrets = new WeakMap()
|
|
24
|
+
const secrets = new WeakMap();
|
|
25
25
|
|
|
26
26
|
export interface Keypair {
|
|
27
|
-
publicKey:
|
|
28
|
-
secretKey: string | Uint8Array
|
|
27
|
+
publicKey: Encoded.AccountAddress;
|
|
28
|
+
secretKey: string | Uint8Array;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* In-memory account class
|
|
33
33
|
*/
|
|
34
34
|
export default class AccountMemory extends AccountBase {
|
|
35
|
-
isGa: boolean
|
|
35
|
+
isGa: boolean;
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* @param options - Options
|
|
@@ -41,43 +41,58 @@ export default class AccountMemory extends AccountBase {
|
|
|
41
41
|
* @param options.keypair.secretKey - Private key
|
|
42
42
|
* @param options.gaId - Address of generalized account
|
|
43
43
|
*/
|
|
44
|
-
constructor
|
|
45
|
-
{ keypair, gaId, ...options }: { keypair?: Keypair
|
|
44
|
+
constructor(
|
|
45
|
+
{ keypair, gaId, ...options }: { keypair?: Keypair; gaId?: Encoded.AccountAddress }
|
|
46
|
+
& ConstructorParameters<typeof AccountBase>[0],
|
|
46
47
|
) {
|
|
47
|
-
super(options)
|
|
48
|
+
super(options);
|
|
48
49
|
|
|
49
|
-
this.isGa = gaId != null
|
|
50
|
+
this.isGa = gaId != null;
|
|
50
51
|
if (this.isGa && gaId != null) {
|
|
51
|
-
decode(gaId)
|
|
52
|
-
secrets.set(this, { publicKey: gaId })
|
|
53
|
-
return
|
|
52
|
+
decode(gaId);
|
|
53
|
+
secrets.set(this, { publicKey: gaId });
|
|
54
|
+
return;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
if (keypair == null) throw new MissingParamError('Either gaId or keypair is required')
|
|
57
|
+
if (keypair == null) throw new MissingParamError('Either gaId or keypair is required');
|
|
57
58
|
|
|
58
59
|
if (
|
|
59
|
-
!Buffer.isBuffer(keypair.secretKey)
|
|
60
|
-
typeof keypair.secretKey === 'string' && !isHex(keypair.secretKey)
|
|
61
|
-
) throw new InvalidKeypairError('Secret key must be hex string or Buffer')
|
|
60
|
+
!Buffer.isBuffer(keypair.secretKey)
|
|
61
|
+
&& typeof keypair.secretKey === 'string' && !isHex(keypair.secretKey)
|
|
62
|
+
) throw new InvalidKeypairError('Secret key must be hex string or Buffer');
|
|
62
63
|
const secretKey = typeof keypair.secretKey === 'string'
|
|
63
64
|
? Buffer.from(keypair.secretKey, 'hex')
|
|
64
|
-
: keypair.secretKey
|
|
65
|
+
: keypair.secretKey;
|
|
65
66
|
if (!isValidKeypair(secretKey, decode(keypair.publicKey))) {
|
|
66
|
-
throw new InvalidKeypairError('Invalid Key Pair')
|
|
67
|
+
throw new InvalidKeypairError('Invalid Key Pair');
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
secrets.set(this, {
|
|
70
71
|
secretKey,
|
|
71
|
-
publicKey: keypair.publicKey
|
|
72
|
-
})
|
|
72
|
+
publicKey: keypair.publicKey,
|
|
73
|
+
});
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
async sign
|
|
76
|
-
if (this.isGa) throw new InvalidKeypairError('You are trying to sign data using generalized account without keypair')
|
|
77
|
-
return sign(data, secrets.get(this).secretKey)
|
|
76
|
+
async sign(data: string | Uint8Array): Promise<Uint8Array> {
|
|
77
|
+
if (this.isGa) throw new InvalidKeypairError('You are trying to sign data using generalized account without keypair');
|
|
78
|
+
return sign(data, secrets.get(this).secretKey);
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
async
|
|
81
|
-
|
|
81
|
+
async signTransaction(
|
|
82
|
+
tx: Encoded.Transaction,
|
|
83
|
+
options: Parameters<AccountBase['signTransaction']>[1] = {},
|
|
84
|
+
): Promise<Encoded.Transaction> {
|
|
85
|
+
if (!this.isGa || options.innerTx === true) return super.signTransaction(tx, options);
|
|
86
|
+
const {
|
|
87
|
+
authData, authFun, onCompiler, onNode,
|
|
88
|
+
} = options;
|
|
89
|
+
if (authFun == null || authData == null || onCompiler == null || onNode == null) {
|
|
90
|
+
throw new ArgumentError('authData, authFun, onCompiler, onNode', 'provided', null);
|
|
91
|
+
}
|
|
92
|
+
return createMetaTx(tx, authData, authFun, { onCompiler, onNode, onAccount: this });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async address(): Promise<Encoded.AccountAddress> {
|
|
96
|
+
return secrets.get(this).publicKey;
|
|
82
97
|
}
|
|
83
98
|
}
|
package/src/account/Rpc.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import AccountBase from './Base'
|
|
2
|
-
import { METHODS } from '../aepp-wallet-communication/schema'
|
|
3
|
-
import { NotImplementedError } from '../utils/errors'
|
|
4
|
-
import {
|
|
1
|
+
import AccountBase from './Base';
|
|
2
|
+
import { METHODS } from '../aepp-wallet-communication/schema';
|
|
3
|
+
import { NotImplementedError } from '../utils/errors';
|
|
4
|
+
import { Encoded } from '../utils/encoder';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Account provided by wallet
|
|
@@ -11,34 +11,36 @@ import { EncodedData } from '../utils/encoder'
|
|
|
11
11
|
* @returns AccountRpc instance
|
|
12
12
|
*/
|
|
13
13
|
export default class AccountRpc extends AccountBase {
|
|
14
|
-
_rpcClient: any
|
|
15
|
-
_address: EncodedData<'ak'>
|
|
14
|
+
_rpcClient: any;
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
_address: Encoded.AccountAddress;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
{ rpcClient, address, ...options }: { rpcClient: any; address: Encoded.AccountAddress }
|
|
20
|
+
& ConstructorParameters<typeof AccountBase>[0],
|
|
20
21
|
) {
|
|
21
|
-
super(options)
|
|
22
|
-
this._rpcClient = rpcClient
|
|
23
|
-
this._address = address
|
|
22
|
+
super(options);
|
|
23
|
+
this._rpcClient = rpcClient;
|
|
24
|
+
this._address = address;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
// eslint-disable-next-line class-methods-use-this
|
|
28
|
+
async sign(): Promise<Uint8Array> {
|
|
29
|
+
throw new NotImplementedError('RAW signing using wallet');
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
async address
|
|
31
|
-
return this._address
|
|
32
|
+
async address(): Promise<Encoded.AccountAddress> {
|
|
33
|
+
return this._address;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
37
|
* @returns Signed transaction
|
|
36
38
|
*/
|
|
37
|
-
async signTransaction
|
|
38
|
-
tx:
|
|
39
|
-
{ innerTx, networkId }: Parameters<AccountBase['signTransaction']>[1] = {}
|
|
40
|
-
): Promise<
|
|
41
|
-
if (innerTx != null) throw new NotImplementedError('innerTx option in AccountRpc')
|
|
39
|
+
async signTransaction(
|
|
40
|
+
tx: Encoded.Transaction,
|
|
41
|
+
{ innerTx, networkId }: Parameters<AccountBase['signTransaction']>[1] = {},
|
|
42
|
+
): Promise<Encoded.Transaction> {
|
|
43
|
+
if (innerTx != null) throw new NotImplementedError('innerTx option in AccountRpc');
|
|
42
44
|
const res = await this._rpcClient.request(METHODS.sign, {
|
|
43
45
|
onAccount: this._address,
|
|
44
46
|
tx,
|
|
@@ -48,20 +50,20 @@ export default class AccountRpc extends AccountBase {
|
|
|
48
50
|
* required to maintain backward compatibility with wallets using SDK v11.0.1 and below
|
|
49
51
|
* @see {@link https://github.com/aeternity/aepp-sdk-js/commit/153fd89a52c4eab39fcd659b356b36d32129c1ba}
|
|
50
52
|
*/
|
|
51
|
-
networkId
|
|
52
|
-
})
|
|
53
|
-
return res.signedTransaction
|
|
53
|
+
networkId,
|
|
54
|
+
});
|
|
55
|
+
return res.signedTransaction;
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
/**
|
|
57
59
|
* @returns Signed message
|
|
58
60
|
*/
|
|
59
|
-
async signMessage
|
|
60
|
-
message: string,
|
|
61
|
+
async signMessage(
|
|
62
|
+
message: string,
|
|
63
|
+
{ returnHex = false }: Parameters<AccountBase['signMessage']>[1] = {},
|
|
61
64
|
): Promise<string | Uint8Array> {
|
|
62
|
-
const { signature } = await this._rpcClient
|
|
63
|
-
METHODS.signMessage, { onAccount: this._address, message }
|
|
64
|
-
)
|
|
65
|
-
return returnHex ? signature : Buffer.from(signature, 'hex')
|
|
65
|
+
const { signature } = await this._rpcClient
|
|
66
|
+
.request(METHODS.signMessage, { onAccount: this._address, message });
|
|
67
|
+
return returnHex ? signature : Buffer.from(signature, 'hex');
|
|
66
68
|
}
|
|
67
69
|
}
|