@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/aens.ts
CHANGED
|
@@ -23,25 +23,28 @@
|
|
|
23
23
|
* repository.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import
|
|
26
|
+
import BigNumber from 'bignumber.js';
|
|
27
|
+
import { genSalt } from './utils/crypto';
|
|
28
|
+
import { commitmentHash, isAuctionName } from './tx/builder/helpers';
|
|
29
|
+
import {
|
|
30
|
+
CLIENT_TTL, NAME_TTL, Tag, AensName,
|
|
31
|
+
} from './tx/builder/constants';
|
|
32
|
+
import { ArgumentError } from './utils/errors';
|
|
33
|
+
import { Encoded } from './utils/encoder';
|
|
34
|
+
import { send, SendOptions } from './spend';
|
|
35
|
+
import { getName, getHeight } from './chain';
|
|
36
|
+
import { _buildTx, BuildTxOptions } from './tx';
|
|
37
|
+
import { TransformNodeType } from './Node';
|
|
38
|
+
import { NameEntry, NamePointer } from './apis/node';
|
|
39
|
+
import AccountBase from './account/Base';
|
|
38
40
|
|
|
39
41
|
interface KeyPointers {
|
|
40
|
-
[key: string]: string | Buffer
|
|
42
|
+
[key: string]: string | Buffer;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
/**
|
|
44
46
|
* Revoke a name
|
|
47
|
+
* @category AENS
|
|
45
48
|
* @param name - Name hash
|
|
46
49
|
* @param options - Options
|
|
47
50
|
* @param options.onAccount - Make operation on specific account from sdk (you pass
|
|
@@ -60,23 +63,25 @@ interface KeyPointers {
|
|
|
60
63
|
* await nameObject.revoke({ fee, ttl, nonce })
|
|
61
64
|
* ```
|
|
62
65
|
*/
|
|
63
|
-
export async function aensRevoke
|
|
64
|
-
name: AensName,
|
|
66
|
+
export async function aensRevoke(
|
|
67
|
+
name: AensName,
|
|
68
|
+
options: AensRevokeOptions,
|
|
65
69
|
): ReturnType<typeof send> {
|
|
66
|
-
const nameRevokeTx = await _buildTx(
|
|
70
|
+
const nameRevokeTx = await _buildTx(Tag.NameRevokeTx, {
|
|
67
71
|
...options,
|
|
68
72
|
nameId: name,
|
|
69
|
-
accountId: await options.onAccount.address(options)
|
|
70
|
-
})
|
|
71
|
-
return
|
|
73
|
+
accountId: await options.onAccount.address(options),
|
|
74
|
+
});
|
|
75
|
+
return send(nameRevokeTx, options);
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
interface AensRevokeOptions extends
|
|
75
|
-
BuildTxOptions<
|
|
79
|
+
BuildTxOptions<Tag.NameRevokeTx, 'nameId' | 'accountId'>,
|
|
76
80
|
SendOptions {}
|
|
77
81
|
|
|
78
82
|
/**
|
|
79
83
|
* Update a name
|
|
84
|
+
* @category AENS
|
|
80
85
|
* @param name - AENS name
|
|
81
86
|
* @param pointers - Map of pointer keys to corresponding addresses
|
|
82
87
|
* @param options - Options
|
|
@@ -103,39 +108,42 @@ interface AensRevokeOptions extends
|
|
|
103
108
|
* await nameObject.update(pointers, { nameTtl, ttl, fee, nonce, clientTtl })
|
|
104
109
|
* ```
|
|
105
110
|
*/
|
|
106
|
-
export async function aensUpdate
|
|
107
|
-
name: AensName,
|
|
111
|
+
export async function aensUpdate(
|
|
112
|
+
name: AensName,
|
|
113
|
+
pointers: KeyPointers,
|
|
114
|
+
{ extendPointers, ...options }: AensUpdateOptions,
|
|
108
115
|
): ReturnType<typeof send> {
|
|
109
116
|
const allPointers = {
|
|
110
117
|
...extendPointers === true && Object.fromEntries(
|
|
111
118
|
(await getName(name, options)).pointers
|
|
112
|
-
.map(({ key, id }: { key: string
|
|
119
|
+
.map(({ key, id }: { key: string; id: string }) => [key, id]),
|
|
113
120
|
),
|
|
114
|
-
...pointers
|
|
115
|
-
}
|
|
121
|
+
...pointers,
|
|
122
|
+
};
|
|
116
123
|
|
|
117
|
-
const nameUpdateTx = await _buildTx(
|
|
124
|
+
const nameUpdateTx = await _buildTx(Tag.NameUpdateTx, {
|
|
118
125
|
clientTtl: CLIENT_TTL,
|
|
119
126
|
nameTtl: NAME_TTL,
|
|
120
127
|
...options,
|
|
121
128
|
nameId: name,
|
|
122
129
|
accountId: await options.onAccount.address(options),
|
|
123
|
-
pointers: Object.entries(allPointers).map(([key, id]) => ({ key, id: id.toString() }))
|
|
124
|
-
})
|
|
130
|
+
pointers: Object.entries(allPointers).map(([key, id]) => ({ key, id: id.toString() })),
|
|
131
|
+
});
|
|
125
132
|
|
|
126
|
-
return
|
|
133
|
+
return send(nameUpdateTx, options);
|
|
127
134
|
}
|
|
128
135
|
|
|
129
136
|
interface AensUpdateOptions extends
|
|
130
|
-
BuildTxOptions<
|
|
137
|
+
BuildTxOptions<Tag.NameUpdateTx, 'nameId' | 'accountId' | 'pointers' | 'clientTtl' | 'nameTtl'>,
|
|
131
138
|
SendOptions {
|
|
132
|
-
extendPointers?: boolean
|
|
133
|
-
clientTtl?: number
|
|
134
|
-
nameTtl?: number
|
|
139
|
+
extendPointers?: boolean;
|
|
140
|
+
clientTtl?: number;
|
|
141
|
+
nameTtl?: number;
|
|
135
142
|
}
|
|
136
143
|
|
|
137
144
|
/**
|
|
138
145
|
* Transfer a domain to another account
|
|
146
|
+
* @category AENS
|
|
139
147
|
* @param name - AENS name
|
|
140
148
|
* @param account - Recipient account publick key
|
|
141
149
|
* @param options - Options
|
|
@@ -156,26 +164,29 @@ interface AensUpdateOptions extends
|
|
|
156
164
|
* await nameObject.transfer(recipientPub, { ttl, fee, nonce })
|
|
157
165
|
* ```
|
|
158
166
|
*/
|
|
159
|
-
export async function aensTransfer
|
|
160
|
-
name: AensName,
|
|
167
|
+
export async function aensTransfer(
|
|
168
|
+
name: AensName,
|
|
169
|
+
account: Encoded.AccountAddress,
|
|
170
|
+
options: AensTransferOptions,
|
|
161
171
|
): ReturnType<typeof send> {
|
|
162
|
-
const nameTransferTx = await _buildTx(
|
|
172
|
+
const nameTransferTx = await _buildTx(Tag.NameTransferTx, {
|
|
163
173
|
...options,
|
|
164
174
|
nameId: name,
|
|
165
175
|
accountId: await options.onAccount.address(options),
|
|
166
|
-
recipientId: account
|
|
167
|
-
})
|
|
176
|
+
recipientId: account,
|
|
177
|
+
});
|
|
168
178
|
|
|
169
|
-
return
|
|
179
|
+
return send(nameTransferTx, options);
|
|
170
180
|
}
|
|
171
181
|
|
|
172
182
|
interface AensTransferOptions extends
|
|
173
|
-
BuildTxOptions<
|
|
183
|
+
BuildTxOptions<Tag.NameTransferTx, 'nameId' | 'accountId' | 'recipientId'>,
|
|
174
184
|
SendOptions {}
|
|
175
185
|
|
|
176
186
|
/**
|
|
177
187
|
* Query the AENS name info from the node
|
|
178
188
|
* and return the object with info and predefined functions for manipulating name
|
|
189
|
+
* @category AENS
|
|
179
190
|
* @param name - AENS name
|
|
180
191
|
* @param opt - Options
|
|
181
192
|
* @returns
|
|
@@ -193,72 +204,75 @@ interface AensTransferOptions extends
|
|
|
193
204
|
* }
|
|
194
205
|
* ```
|
|
195
206
|
*/
|
|
196
|
-
export async function aensQuery
|
|
207
|
+
export async function aensQuery(
|
|
197
208
|
name: AensName,
|
|
198
209
|
opt: Parameters<typeof getName>[1] & Parameters<typeof aensUpdate>[2]
|
|
199
|
-
& Parameters<typeof aensTransfer>[2]
|
|
210
|
+
& Parameters<typeof aensTransfer>[2],
|
|
200
211
|
): Promise<Readonly<
|
|
201
212
|
TransformNodeType<NameEntry> & {
|
|
202
|
-
id:
|
|
203
|
-
owner:
|
|
204
|
-
pointers: KeyPointers |
|
|
205
|
-
ttl: number
|
|
213
|
+
id: Encoded.Name;
|
|
214
|
+
owner: Encoded.AccountAddress;
|
|
215
|
+
pointers: KeyPointers | NamePointer[];
|
|
216
|
+
ttl: number;
|
|
206
217
|
update: (
|
|
207
218
|
pointers: KeyPointers,
|
|
208
219
|
options?: Omit<Parameters<typeof aensQuery>[1], 'onNode' | 'onCompiler' | 'onAccount'> & {
|
|
209
|
-
onAccount?: AccountBase
|
|
220
|
+
onAccount?: AccountBase;
|
|
210
221
|
}
|
|
211
|
-
) => ReturnType<typeof aensUpdate> & ReturnType<typeof aensQuery
|
|
222
|
+
) => ReturnType<typeof aensUpdate> & ReturnType<typeof aensQuery>;
|
|
212
223
|
transfer: (
|
|
213
|
-
account:
|
|
224
|
+
account: Encoded.AccountAddress,
|
|
214
225
|
options?: Parameters<typeof aensQuery>[1]
|
|
215
|
-
) => ReturnType<typeof aensUpdate> & ReturnType<typeof aensQuery
|
|
226
|
+
) => ReturnType<typeof aensUpdate> & ReturnType<typeof aensQuery>;
|
|
216
227
|
revoke: (options?: Omit<Parameters<typeof aensRevoke>[1], 'onNode' | 'onCompiler' | 'onAccount'> & {
|
|
217
|
-
onAccount?: AccountBase
|
|
228
|
+
onAccount?: AccountBase;
|
|
218
229
|
}
|
|
219
|
-
) => ReturnType<typeof aensRevoke
|
|
230
|
+
) => ReturnType<typeof aensRevoke>;
|
|
220
231
|
extendTtl: (
|
|
221
232
|
nameTtl: number,
|
|
222
233
|
options?: Omit<Parameters<typeof aensQuery>[1], 'onNode' | 'onCompiler' | 'onAccount'>
|
|
223
|
-
) => ReturnType<typeof aensUpdate> & ReturnType<typeof aensQuery
|
|
234
|
+
) => ReturnType<typeof aensUpdate> & ReturnType<typeof aensQuery>;
|
|
224
235
|
}
|
|
225
236
|
>> {
|
|
226
|
-
const nameEntry = await getName(name, opt)
|
|
237
|
+
const nameEntry = await getName(name, opt);
|
|
227
238
|
return Object.freeze({
|
|
228
239
|
...nameEntry,
|
|
229
|
-
id: nameEntry.id as
|
|
230
|
-
owner: nameEntry.owner as
|
|
231
|
-
async update
|
|
240
|
+
id: nameEntry.id as Encoded.Name,
|
|
241
|
+
owner: nameEntry.owner as Encoded.AccountAddress,
|
|
242
|
+
async update(pointers, options) {
|
|
232
243
|
return {
|
|
233
244
|
...await aensUpdate(name, pointers, { ...opt, ...options }),
|
|
234
|
-
...await aensQuery(name, { ...opt, ...options })
|
|
235
|
-
}
|
|
245
|
+
...await aensQuery(name, { ...opt, ...options }),
|
|
246
|
+
};
|
|
236
247
|
},
|
|
237
|
-
async transfer
|
|
248
|
+
async transfer(account, options) {
|
|
238
249
|
return {
|
|
239
250
|
...await aensTransfer(name, account, { ...opt, ...options }),
|
|
240
|
-
...await aensQuery(name, { ...opt, ...options })
|
|
241
|
-
}
|
|
251
|
+
...await aensQuery(name, { ...opt, ...options }),
|
|
252
|
+
};
|
|
242
253
|
},
|
|
243
|
-
async revoke
|
|
244
|
-
return
|
|
254
|
+
async revoke(options) {
|
|
255
|
+
return aensRevoke(name, { ...opt, ...options });
|
|
245
256
|
},
|
|
246
|
-
async extendTtl
|
|
257
|
+
async extendTtl(nameTtl = NAME_TTL, options = {}) {
|
|
247
258
|
if (nameTtl > NAME_TTL || nameTtl <= 0) {
|
|
248
|
-
throw new ArgumentError('nameTtl', `a number between 1 and ${NAME_TTL} blocks`, nameTtl)
|
|
259
|
+
throw new ArgumentError('nameTtl', `a number between 1 and ${NAME_TTL} blocks`, nameTtl);
|
|
249
260
|
}
|
|
250
261
|
|
|
251
262
|
return {
|
|
252
|
-
...await aensUpdate(name, {}, {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
263
|
+
...await aensUpdate(name, {}, {
|
|
264
|
+
...opt, ...options, nameTtl, extendPointers: true,
|
|
265
|
+
}),
|
|
266
|
+
...await aensQuery(name, { ...opt, ...options }),
|
|
267
|
+
};
|
|
268
|
+
},
|
|
269
|
+
});
|
|
257
270
|
}
|
|
258
271
|
|
|
259
272
|
/**
|
|
260
273
|
* Claim a previously preclaimed registration. This can only be done after the
|
|
261
274
|
* preclaim step
|
|
275
|
+
* @category AENS
|
|
262
276
|
* @param name - AENS name
|
|
263
277
|
* @param salt - Salt from pre-claim, or 0 if it's a bid
|
|
264
278
|
* @param options - options
|
|
@@ -277,28 +291,30 @@ export async function aensQuery (
|
|
|
277
291
|
* await sdkInstance.aensClaim(name, salt, { ttl, fee, nonce, nameFee })
|
|
278
292
|
* ```
|
|
279
293
|
*/
|
|
280
|
-
export async function aensClaim
|
|
281
|
-
name: AensName,
|
|
294
|
+
export async function aensClaim(
|
|
295
|
+
name: AensName,
|
|
296
|
+
salt: number,
|
|
297
|
+
options: AensClaimOptions,
|
|
282
298
|
): Promise<AensClaimReturnType> {
|
|
283
|
-
const claimTx = await _buildTx(
|
|
299
|
+
const claimTx = await _buildTx(Tag.NameClaimTx, {
|
|
284
300
|
...options,
|
|
285
301
|
accountId: await options.onAccount.address(options),
|
|
286
302
|
nameSalt: salt,
|
|
287
|
-
name
|
|
288
|
-
})
|
|
303
|
+
name,
|
|
304
|
+
});
|
|
289
305
|
|
|
290
|
-
const result = await send(claimTx, options)
|
|
306
|
+
const result = await send(claimTx, options);
|
|
291
307
|
if (!isAuctionName(name)) {
|
|
292
308
|
const nameInter = result.blockHeight != null && result.blockHeight > 0
|
|
293
309
|
? await aensQuery(name, options)
|
|
294
|
-
: {}
|
|
295
|
-
return Object.assign(result, nameInter)
|
|
310
|
+
: {};
|
|
311
|
+
return Object.assign(result, nameInter);
|
|
296
312
|
}
|
|
297
|
-
return result
|
|
313
|
+
return result;
|
|
298
314
|
}
|
|
299
315
|
|
|
300
|
-
type AensClaimOptionsType = BuildTxOptions<
|
|
301
|
-
& SendOptions & Parameters<typeof aensQuery>[1]
|
|
316
|
+
type AensClaimOptionsType = BuildTxOptions<Tag.NameClaimTx, 'accountId' | 'nameSalt' | 'name'>
|
|
317
|
+
& SendOptions & Parameters<typeof aensQuery>[1];
|
|
302
318
|
interface AensClaimOptions extends AensClaimOptionsType {}
|
|
303
319
|
interface AensClaimReturnType extends
|
|
304
320
|
Awaited<ReturnType<typeof send>>,
|
|
@@ -306,6 +322,7 @@ interface AensClaimReturnType extends
|
|
|
306
322
|
|
|
307
323
|
/**
|
|
308
324
|
* Preclaim a name. Sends a hash of the name and a random salt to the node
|
|
325
|
+
* @category AENS
|
|
309
326
|
* @param name - AENS name
|
|
310
327
|
* @param options - Options
|
|
311
328
|
* @param options.onAccount - Make operation on specific account from sdk (you pass
|
|
@@ -327,44 +344,43 @@ interface AensClaimReturnType extends
|
|
|
327
344
|
* }
|
|
328
345
|
* ```
|
|
329
346
|
*/
|
|
330
|
-
export async function aensPreclaim
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
const currentHeight = await height(options)
|
|
342
|
-
const commitmentId = commitmentHash(name, _salt)
|
|
347
|
+
export async function aensPreclaim(name: AensName, options: AensPreclaimOptions): Promise<Readonly<
|
|
348
|
+
Awaited<ReturnType<typeof send>> & {
|
|
349
|
+
height: number;
|
|
350
|
+
salt: number;
|
|
351
|
+
commitmentId: string;
|
|
352
|
+
claim: (opts?: Parameters<typeof aensClaim>[2]) => ReturnType<typeof aensClaim>;
|
|
353
|
+
}
|
|
354
|
+
>> {
|
|
355
|
+
const salt = genSalt();
|
|
356
|
+
const height = await getHeight(options);
|
|
357
|
+
const commitmentId = commitmentHash(name, salt);
|
|
343
358
|
|
|
344
|
-
const preclaimTx = await _buildTx(
|
|
359
|
+
const preclaimTx = await _buildTx(Tag.NamePreclaimTx, {
|
|
345
360
|
...options,
|
|
346
361
|
accountId: await options.onAccount.address(options),
|
|
347
|
-
commitmentId
|
|
348
|
-
})
|
|
362
|
+
commitmentId,
|
|
363
|
+
});
|
|
349
364
|
|
|
350
365
|
return Object.freeze({
|
|
351
366
|
...await send(preclaimTx, options),
|
|
352
|
-
height
|
|
353
|
-
salt
|
|
367
|
+
height,
|
|
368
|
+
salt,
|
|
354
369
|
commitmentId,
|
|
355
|
-
async claim
|
|
356
|
-
return
|
|
357
|
-
}
|
|
358
|
-
})
|
|
370
|
+
async claim(opts?: Parameters<typeof aensClaim>[2]) {
|
|
371
|
+
return aensClaim(name, salt, { ...options, ...opts });
|
|
372
|
+
},
|
|
373
|
+
});
|
|
359
374
|
}
|
|
360
375
|
|
|
361
376
|
interface AensPreclaimOptions extends
|
|
362
|
-
BuildTxOptions<
|
|
377
|
+
BuildTxOptions<Tag.NamePreclaimTx, 'accountId' | 'commitmentId'>,
|
|
363
378
|
SendOptions,
|
|
364
379
|
AensClaimOptions {}
|
|
365
380
|
|
|
366
381
|
/**
|
|
367
382
|
* Bid to name auction
|
|
383
|
+
* @category AENS
|
|
368
384
|
* @param name - Domain name
|
|
369
385
|
* @param nameFee - Name fee (bid fee)
|
|
370
386
|
* @param options - Options
|
|
@@ -382,10 +398,10 @@ interface AensPreclaimOptions extends
|
|
|
382
398
|
* await sdkInstance.aensBid(name, 213109412839123, { ttl, fee, nonce })
|
|
383
399
|
* ```
|
|
384
400
|
*/
|
|
385
|
-
export async function aensBid
|
|
401
|
+
export async function aensBid(
|
|
386
402
|
name: AensName,
|
|
387
403
|
nameFee: number | string | BigNumber,
|
|
388
|
-
options: Omit<Parameters<typeof aensClaim>[2], 'nameFee'
|
|
404
|
+
options: Omit<Parameters<typeof aensClaim>[2], 'nameFee'>,
|
|
389
405
|
): ReturnType<typeof aensClaim> {
|
|
390
|
-
return
|
|
406
|
+
return aensClaim(name, 0, { ...options, nameFee });
|
|
391
407
|
}
|
|
@@ -15,16 +15,17 @@
|
|
|
15
15
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { AlreadyConnectedError, NoWalletConnectedError } from '../../utils/errors'
|
|
18
|
+
import { AlreadyConnectedError, NoWalletConnectedError } from '../../utils/errors';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Browser connection base interface
|
|
22
|
+
* @category aepp wallet communication
|
|
22
23
|
*/
|
|
23
24
|
export default abstract class BrowserConnection {
|
|
24
|
-
debug: boolean
|
|
25
|
+
debug: boolean;
|
|
25
26
|
|
|
26
|
-
protected constructor
|
|
27
|
-
this.debug = debug
|
|
27
|
+
protected constructor({ debug = false }: { debug?: boolean }) {
|
|
28
|
+
this.debug = debug;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
/**
|
|
@@ -32,37 +33,39 @@ export default abstract class BrowserConnection {
|
|
|
32
33
|
* @param onMessage - Message handler
|
|
33
34
|
* @param onDisconnect - trigger when runtime connection in closed
|
|
34
35
|
*/
|
|
35
|
-
connect
|
|
36
|
+
connect(
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
36
38
|
onMessage: (message: any, origin: string, source: any) => void,
|
|
37
|
-
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
40
|
+
onDisconnect: () => void,
|
|
38
41
|
): void {
|
|
39
|
-
if (this.isConnected()) throw new AlreadyConnectedError('You already connected')
|
|
42
|
+
if (this.isConnected()) throw new AlreadyConnectedError('You already connected');
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
/**
|
|
43
46
|
* Disconnect
|
|
44
47
|
*/
|
|
45
|
-
disconnect
|
|
46
|
-
if (!this.isConnected()) throw new NoWalletConnectedError('You dont have connection. Please connect before')
|
|
48
|
+
disconnect(): void {
|
|
49
|
+
if (!this.isConnected()) throw new NoWalletConnectedError('You dont have connection. Please connect before');
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
/**
|
|
50
|
-
*
|
|
53
|
+
* Receive message
|
|
51
54
|
*/
|
|
52
|
-
protected receiveMessage
|
|
53
|
-
if (this.debug) console.log('Receive message:', message)
|
|
55
|
+
protected receiveMessage(message: any): void {
|
|
56
|
+
if (this.debug) console.log('Receive message:', message);
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
/**
|
|
57
60
|
* Send message
|
|
58
61
|
*/
|
|
59
|
-
sendMessage
|
|
60
|
-
if (this.debug) console.log('Send message:', message)
|
|
62
|
+
sendMessage(message: any): void {
|
|
63
|
+
if (this.debug) console.log('Send message:', message);
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
/**
|
|
64
67
|
* Check if connected
|
|
65
68
|
* @returns Is connected
|
|
66
69
|
*/
|
|
67
|
-
abstract isConnected
|
|
70
|
+
abstract isConnected(): boolean;
|
|
68
71
|
}
|
|
@@ -15,44 +15,45 @@
|
|
|
15
15
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { Runtime } from 'webextension-polyfill'
|
|
19
|
-
import BrowserConnection from './Browser'
|
|
18
|
+
import { Runtime } from 'webextension-polyfill';
|
|
19
|
+
import BrowserConnection from './Browser';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* BrowserRuntimeConnection
|
|
23
23
|
* Handle browser runtime communication
|
|
24
|
+
* @category aepp wallet communication
|
|
24
25
|
*/
|
|
25
26
|
export default class BrowserRuntimeConnection extends BrowserConnection {
|
|
26
|
-
port: Runtime.Port
|
|
27
|
+
port: Runtime.Port;
|
|
27
28
|
|
|
28
|
-
constructor
|
|
29
|
-
super(options)
|
|
30
|
-
this.port = port
|
|
29
|
+
constructor({ port, ...options }: { port: Runtime.Port; debug: boolean }) {
|
|
30
|
+
super(options);
|
|
31
|
+
this.port = port;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
disconnect
|
|
34
|
-
super.disconnect()
|
|
35
|
-
this.port.disconnect()
|
|
34
|
+
disconnect(): void {
|
|
35
|
+
super.disconnect();
|
|
36
|
+
this.port.disconnect();
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
connect
|
|
39
|
+
connect(
|
|
39
40
|
onMessage: (message: any, origin: string, source: Runtime.Port) => void,
|
|
40
|
-
onDisconnect: () => void
|
|
41
|
+
onDisconnect: () => void,
|
|
41
42
|
): void {
|
|
42
|
-
super.connect(onMessage, onDisconnect)
|
|
43
|
+
super.connect(onMessage, onDisconnect);
|
|
43
44
|
this.port.onMessage.addListener((message, port) => {
|
|
44
|
-
this.receiveMessage(message)
|
|
45
|
-
onMessage(message, port.name, port)
|
|
46
|
-
})
|
|
47
|
-
this.port.onDisconnect.addListener(onDisconnect)
|
|
45
|
+
this.receiveMessage(message);
|
|
46
|
+
onMessage(message, port.name, port);
|
|
47
|
+
});
|
|
48
|
+
this.port.onDisconnect.addListener(onDisconnect);
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
sendMessage
|
|
51
|
-
super.sendMessage(message)
|
|
52
|
-
this.port.postMessage(message)
|
|
51
|
+
sendMessage(message: any): void {
|
|
52
|
+
super.sendMessage(message);
|
|
53
|
+
this.port.postMessage(message);
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
isConnected
|
|
56
|
-
return this.port.onMessage.hasListeners()
|
|
56
|
+
isConnected(): boolean {
|
|
57
|
+
return this.port.onMessage.hasListeners();
|
|
57
58
|
}
|
|
58
59
|
}
|