@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/src/account/Rpc.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { ArgumentError, NotImplementedError, UnsupportedProtocolError } from '..
|
|
|
4
4
|
import { Encoded } from '../utils/encoder';
|
|
5
5
|
import RpcClient from '../aepp-wallet-communication/rpc/RpcClient';
|
|
6
6
|
import { AeppApi, WalletApi } from '../aepp-wallet-communication/rpc/types';
|
|
7
|
+
import { AensName } from '../tx/builder/constants';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Account provided by wallet
|
|
@@ -28,20 +29,17 @@ export default class AccountRpc extends AccountBase {
|
|
|
28
29
|
throw new NotImplementedError('RAW signing using wallet');
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
/**
|
|
32
|
-
* @returns Signed transaction
|
|
33
|
-
*/
|
|
34
32
|
override async signTransaction(
|
|
35
33
|
tx: Encoded.Transaction,
|
|
36
34
|
{ innerTx, networkId }: Parameters<AccountBase['signTransaction']>[1] = {},
|
|
37
35
|
): Promise<Encoded.Transaction> {
|
|
38
|
-
if (innerTx != null) throw new NotImplementedError('innerTx option in AccountRpc');
|
|
39
36
|
if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);
|
|
40
37
|
const res = await this._rpcClient.request(METHODS.sign, {
|
|
41
38
|
onAccount: this.address,
|
|
42
39
|
tx,
|
|
43
40
|
returnSigned: true,
|
|
44
41
|
networkId,
|
|
42
|
+
innerTx,
|
|
45
43
|
});
|
|
46
44
|
if (res.signedTransaction == null) {
|
|
47
45
|
throw new UnsupportedProtocolError('signedTransaction is missed in wallet response');
|
|
@@ -49,12 +47,61 @@ export default class AccountRpc extends AccountBase {
|
|
|
49
47
|
return res.signedTransaction;
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
/**
|
|
53
|
-
* @returns Signed message
|
|
54
|
-
*/
|
|
55
50
|
override async signMessage(message: string): Promise<Uint8Array> {
|
|
56
51
|
const { signature } = await this._rpcClient
|
|
57
52
|
.request(METHODS.signMessage, { onAccount: this.address, message });
|
|
58
53
|
return Buffer.from(signature, 'hex');
|
|
59
54
|
}
|
|
55
|
+
|
|
56
|
+
override async signTypedData(
|
|
57
|
+
data: Encoded.ContractBytearray,
|
|
58
|
+
aci: Parameters<AccountBase['signTypedData']>[1],
|
|
59
|
+
{
|
|
60
|
+
name, version, contractAddress, networkId,
|
|
61
|
+
}: Parameters<AccountBase['signTypedData']>[2] = {},
|
|
62
|
+
): Promise<Encoded.Signature> {
|
|
63
|
+
const { signature } = await this._rpcClient.request(METHODS.signTypedData, {
|
|
64
|
+
onAccount: this.address,
|
|
65
|
+
domain: {
|
|
66
|
+
name, version, networkId, contractAddress,
|
|
67
|
+
},
|
|
68
|
+
aci,
|
|
69
|
+
data,
|
|
70
|
+
});
|
|
71
|
+
return signature;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
override async signDelegationToContract(
|
|
75
|
+
contractAddress: Encoded.ContractAddress,
|
|
76
|
+
): Promise<Encoded.Signature> {
|
|
77
|
+
const { signature } = await this._rpcClient.request(METHODS.signDelegationToContract, {
|
|
78
|
+
onAccount: this.address,
|
|
79
|
+
contractAddress,
|
|
80
|
+
});
|
|
81
|
+
return signature;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
override async signNameDelegationToContract(
|
|
85
|
+
contractAddress: Encoded.ContractAddress,
|
|
86
|
+
name: AensName,
|
|
87
|
+
): Promise<Encoded.Signature> {
|
|
88
|
+
const { signature } = await this._rpcClient.request(METHODS.signDelegationToContract, {
|
|
89
|
+
onAccount: this.address,
|
|
90
|
+
contractAddress,
|
|
91
|
+
name,
|
|
92
|
+
});
|
|
93
|
+
return signature;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
override async signOracleQueryDelegationToContract(
|
|
97
|
+
contractAddress: Encoded.ContractAddress,
|
|
98
|
+
oracleQueryId: Encoded.OracleQueryId,
|
|
99
|
+
): Promise<Encoded.Signature> {
|
|
100
|
+
const { signature } = await this._rpcClient.request(METHODS.signDelegationToContract, {
|
|
101
|
+
onAccount: this.address,
|
|
102
|
+
contractAddress,
|
|
103
|
+
oracleQueryId,
|
|
104
|
+
});
|
|
105
|
+
return signature;
|
|
106
|
+
}
|
|
60
107
|
}
|
package/src/aens.ts
CHANGED
|
@@ -379,7 +379,7 @@ interface AensPreclaimOptions extends
|
|
|
379
379
|
* @example
|
|
380
380
|
* ```js
|
|
381
381
|
* const name = 'test.chain'
|
|
382
|
-
* const bidFee = computeBidFee(name, startFee,
|
|
382
|
+
* const bidFee = computeBidFee(name, { startFee, increment: 0.42 })
|
|
383
383
|
*
|
|
384
384
|
* await sdkInstance.aensBid(name, 213109412839123, { ttl, fee, nonce })
|
|
385
385
|
* ```
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RpcError, RpcInternalError, RpcMethodNotFoundError } from '../schema';
|
|
2
2
|
import BrowserConnection from '../connection/Browser';
|
|
3
3
|
import { InvalidRpcMessageError, MissingCallbackError } from '../../utils/errors';
|
|
4
|
+
import { ensureError } from '../../utils/other';
|
|
4
5
|
|
|
5
6
|
interface JsonRpcRequest {
|
|
6
7
|
jsonrpc: '2.0';
|
|
@@ -64,17 +65,24 @@ export default class RpcClient <
|
|
|
64
65
|
|
|
65
66
|
const request = msg as JsonRpcRequest;
|
|
66
67
|
let result;
|
|
67
|
-
let error;
|
|
68
|
+
let error: Error | undefined;
|
|
68
69
|
try {
|
|
69
70
|
if (!(request.method in this.#methods)) throw new RpcMethodNotFoundError();
|
|
70
71
|
const methodName = request.method as keyof LocalApi;
|
|
71
72
|
result = await this.#methods[methodName](request.params, origin);
|
|
72
73
|
} catch (e) {
|
|
73
|
-
|
|
74
|
+
ensureError(e);
|
|
75
|
+
error = e;
|
|
74
76
|
}
|
|
75
77
|
if (request.id != null) {
|
|
76
|
-
this.#sendResponse(
|
|
78
|
+
this.#sendResponse(
|
|
79
|
+
request.id,
|
|
80
|
+
request.method as keyof LocalApi,
|
|
81
|
+
result,
|
|
82
|
+
error == null || error instanceof RpcError ? error : new RpcInternalError(),
|
|
83
|
+
);
|
|
77
84
|
}
|
|
85
|
+
if (error != null && !(error instanceof RpcError)) throw error;
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
#sendRequest(
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Encoded } from '../../utils/encoder';
|
|
2
|
+
import { Domain, AciValue } from '../../utils/typed-data';
|
|
2
3
|
import { METHODS, SUBSCRIPTION_TYPES, WALLET_TYPE } from '../schema';
|
|
3
4
|
import { TransformNodeType } from '../../Node';
|
|
4
5
|
import { SignedTx } from '../../apis/node';
|
|
6
|
+
import { AensName } from '../../tx/builder/constants';
|
|
5
7
|
|
|
6
8
|
export interface WalletInfo {
|
|
7
9
|
id: string;
|
|
@@ -55,6 +57,7 @@ export interface WalletApi {
|
|
|
55
57
|
* @see {@link https://github.com/aeternity/aepp-sdk-js/commit/153fd89a52c4eab39fcd659b356b36d32129c1ba}
|
|
56
58
|
*/
|
|
57
59
|
networkId: string;
|
|
60
|
+
innerTx?: boolean;
|
|
58
61
|
}
|
|
59
62
|
) => Promise<{
|
|
60
63
|
/**
|
|
@@ -71,6 +74,24 @@ export interface WalletApi {
|
|
|
71
74
|
[METHODS.signMessage]: (
|
|
72
75
|
p: { message: string; onAccount: Encoded.AccountAddress }
|
|
73
76
|
) => Promise<{ signature: string }>;
|
|
77
|
+
|
|
78
|
+
[METHODS.signTypedData]: (
|
|
79
|
+
p: {
|
|
80
|
+
domain: Domain;
|
|
81
|
+
aci: AciValue;
|
|
82
|
+
data: Encoded.ContractBytearray;
|
|
83
|
+
onAccount: Encoded.AccountAddress;
|
|
84
|
+
},
|
|
85
|
+
) => Promise<{ signature: Encoded.Signature }>;
|
|
86
|
+
|
|
87
|
+
[METHODS.signDelegationToContract]: (
|
|
88
|
+
p: {
|
|
89
|
+
contractAddress: Encoded.ContractAddress;
|
|
90
|
+
name?: AensName;
|
|
91
|
+
oracleQueryId?: Encoded.OracleQueryId;
|
|
92
|
+
onAccount: Encoded.AccountAddress;
|
|
93
|
+
},
|
|
94
|
+
) => Promise<{ signature: Encoded.Signature }>;
|
|
74
95
|
}
|
|
75
96
|
|
|
76
97
|
export interface AeppApi {
|
|
@@ -36,6 +36,8 @@ export const enum METHODS {
|
|
|
36
36
|
connect = 'connection.open',
|
|
37
37
|
sign = 'transaction.sign',
|
|
38
38
|
signMessage = 'message.sign',
|
|
39
|
+
signTypedData = 'typedData.sign',
|
|
40
|
+
signDelegationToContract = 'delegationToContract.sign',
|
|
39
41
|
subscribeAddress = 'address.subscribe',
|
|
40
42
|
updateNetwork = 'networkId.update',
|
|
41
43
|
closeConnection = 'connection.close',
|
|
@@ -64,7 +66,7 @@ const rpcErrors: Array<(new (data?: any) => RpcError) & { code: number }> = [];
|
|
|
64
66
|
export abstract class RpcError extends BaseError {
|
|
65
67
|
static code: number;
|
|
66
68
|
|
|
67
|
-
code
|
|
69
|
+
code!: number;
|
|
68
70
|
|
|
69
71
|
data?: any;
|
|
70
72
|
|
|
@@ -99,22 +101,6 @@ export class RpcInvalidTransactionError extends RpcError {
|
|
|
99
101
|
}
|
|
100
102
|
rpcErrors.push(RpcInvalidTransactionError);
|
|
101
103
|
|
|
102
|
-
/**
|
|
103
|
-
* @category exception
|
|
104
|
-
*/
|
|
105
|
-
export class RpcBroadcastError extends RpcError {
|
|
106
|
-
static override code = 3;
|
|
107
|
-
|
|
108
|
-
override code = 3;
|
|
109
|
-
|
|
110
|
-
constructor(data?: any) {
|
|
111
|
-
super('Broadcast failed');
|
|
112
|
-
this.data = data;
|
|
113
|
-
this.name = 'RpcBroadcastError';
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
rpcErrors.push(RpcBroadcastError);
|
|
117
|
-
|
|
118
104
|
/**
|
|
119
105
|
* @category exception
|
|
120
106
|
*/
|
|
@@ -22,7 +22,7 @@ interface Wallets { [key: string]: Wallet }
|
|
|
22
22
|
*/
|
|
23
23
|
export default (
|
|
24
24
|
connection: BrowserConnection,
|
|
25
|
-
onDetected: ({ wallets, newWallet }: { wallets: Wallets; newWallet
|
|
25
|
+
onDetected: ({ wallets, newWallet }: { wallets: Wallets; newWallet: Wallet }) => void,
|
|
26
26
|
): () => void => {
|
|
27
27
|
if (window == null) throw new UnsupportedPlatformError('Window object not found, you can run wallet detector only in browser');
|
|
28
28
|
const wallets: Wallets = {};
|
|
@@ -49,7 +49,6 @@ export default (
|
|
|
49
49
|
wallets[wallet.info.id] = wallet;
|
|
50
50
|
onDetected({ wallets, newWallet: wallet });
|
|
51
51
|
}, () => {});
|
|
52
|
-
if (Object.keys(wallets).length > 0) onDetected({ wallets });
|
|
53
52
|
|
|
54
53
|
return () => connection.disconnect();
|
|
55
54
|
};
|
|
@@ -260,7 +260,14 @@ const generateACIOperationSpec: coreClient.OperationSpec = {
|
|
|
260
260
|
httpMethod: "POST",
|
|
261
261
|
responses: {
|
|
262
262
|
200: {
|
|
263
|
-
bodyMapper:
|
|
263
|
+
bodyMapper: {
|
|
264
|
+
type: {
|
|
265
|
+
name: "Sequence",
|
|
266
|
+
element: {
|
|
267
|
+
type: { name: "Dictionary", value: { type: { name: "any" } } }
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
264
271
|
},
|
|
265
272
|
400: {
|
|
266
273
|
bodyMapper: {
|
|
@@ -12,13 +12,6 @@ export interface CompileOpts {
|
|
|
12
12
|
srcFile?: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export interface Aci {
|
|
16
|
-
/** Any object */
|
|
17
|
-
encodedAci: Record<string, unknown>;
|
|
18
|
-
externalEncodedAci?: Record<string, unknown>[];
|
|
19
|
-
interface: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
15
|
export interface CompilerError {
|
|
23
16
|
type: string;
|
|
24
17
|
pos: ErrorPos;
|
|
@@ -151,7 +144,7 @@ export interface GenerateACIOptionalParams
|
|
|
151
144
|
extends coreClient.OperationOptions {}
|
|
152
145
|
|
|
153
146
|
/** Contains response data for the generateACI operation. */
|
|
154
|
-
export type GenerateACIResponse =
|
|
147
|
+
export type GenerateACIResponse = Record<string, unknown>[];
|
|
155
148
|
|
|
156
149
|
/** Optional parameters. */
|
|
157
150
|
export interface CompileContractOptionalParams
|
|
@@ -45,42 +45,6 @@ export const CompileOpts: coreClient.CompositeMapper = {
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
export const Aci: coreClient.CompositeMapper = {
|
|
49
|
-
type: {
|
|
50
|
-
name: "Composite",
|
|
51
|
-
className: "Aci",
|
|
52
|
-
modelProperties: {
|
|
53
|
-
encodedAci: {
|
|
54
|
-
serializedName: "encoded_aci",
|
|
55
|
-
required: true,
|
|
56
|
-
type: {
|
|
57
|
-
name: "Dictionary",
|
|
58
|
-
value: { type: { name: "any" } }
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
externalEncodedAci: {
|
|
62
|
-
serializedName: "external_encoded_aci",
|
|
63
|
-
type: {
|
|
64
|
-
name: "Sequence",
|
|
65
|
-
element: {
|
|
66
|
-
type: {
|
|
67
|
-
name: "Dictionary",
|
|
68
|
-
value: { type: { name: "any" } }
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
interface: {
|
|
74
|
-
serializedName: "interface",
|
|
75
|
-
required: true,
|
|
76
|
-
type: {
|
|
77
|
-
name: "String"
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
48
|
export const CompilerError: coreClient.CompositeMapper = {
|
|
85
49
|
type: {
|
|
86
50
|
name: "Composite",
|