@@ -4,8 +4,8 @@ import { printTransaction } from '../utils/print.js';
4
4
import { getNameEntry , validateName } from '../utils/helpers.js' ;
5
5
import CliError from '../utils/CliError.js' ;
6
6
7
- async function ensureNameStatus ( name , sdk , status , operation ) {
8
- const nameEntry = await getNameEntry ( name , sdk ) ;
7
+ async function ensureNameStatus ( name , aeSdk , status , operation ) {
8
+ const nameEntry = await getNameEntry ( name , aeSdk ) ;
9
9
if ( nameEntry . status !== status ) {
10
10
throw new CliError ( `AENS name is ${ nameEntry . status } and cannot be ${ operation } ` ) ;
11
11
}
@@ -16,23 +16,23 @@ export async function preClaim(walletPath, name, options) {
16
16
ttl, fee, nonce, json,
17
17
} = options ;
18
18
validateName ( name ) ;
19
- const sdk = await initSdkByWalletFile ( walletPath , options ) ;
20
- await ensureNameStatus ( name , sdk , 'AVAILABLE' , 'preclaimed' ) ;
21
- const preClaimTx = await sdk . aensPreclaim ( name , { ttl, fee, nonce } ) ;
22
- await printTransaction ( preClaimTx , json , sdk ) ;
19
+ const aeSdk = await initSdkByWalletFile ( walletPath , options ) ;
20
+ await ensureNameStatus ( name , aeSdk , 'AVAILABLE' , 'preclaimed' ) ;
21
+ const preClaimTx = await aeSdk . aensPreclaim ( name , { ttl, fee, nonce } ) ;
22
+ await printTransaction ( preClaimTx , json , aeSdk ) ;
23
23
}
24
24
25
25
export async function claim ( walletPath , name , salt , options ) {
26
26
const {
27
27
ttl, fee, nonce, json, nameFee,
28
28
} = options ;
29
29
validateName ( name ) ;
30
- const sdk = await initSdkByWalletFile ( walletPath , options ) ;
31
- await ensureNameStatus ( name , sdk , 'AVAILABLE' , 'claimed' ) ;
32
- const claimTx = await sdk . aensClaim ( name , salt , {
30
+ const aeSdk = await initSdkByWalletFile ( walletPath , options ) ;
31
+ await ensureNameStatus ( name , aeSdk , 'AVAILABLE' , 'claimed' ) ;
32
+ const claimTx = await aeSdk . aensClaim ( name , salt , {
33
33
nonce, ttl, fee, nameFee,
34
34
} ) ;
35
- await printTransaction ( claimTx , json , sdk ) ;
35
+ await printTransaction ( claimTx , json , aeSdk ) ;
36
36
}
37
37
38
38
export async function updateName ( walletPath , name , addresses , options ) {
@@ -42,29 +42,29 @@ export async function updateName(walletPath, name, addresses, options) {
42
42
const invalidAddresses = addresses . filter ( ( address ) => ! isAddressValid ( address ) ) ;
43
43
if ( invalidAddresses . length ) throw new CliError ( `Addresses "[${ invalidAddresses } ]" is not valid` ) ;
44
44
validateName ( name ) ;
45
- const sdk = await initSdkByWalletFile ( walletPath , options ) ;
46
- await ensureNameStatus ( name , sdk , 'CLAIMED' , 'updated' ) ;
47
- const updateTx = await sdk . aensUpdate (
45
+ const aeSdk = await initSdkByWalletFile ( walletPath , options ) ;
46
+ await ensureNameStatus ( name , aeSdk , 'CLAIMED' , 'updated' ) ;
47
+ const updateTx = await aeSdk . aensUpdate (
48
48
name ,
49
49
Object . fromEntries ( addresses . map ( ( address ) => [ getDefaultPointerKey ( address ) , address ] ) ) ,
50
50
{
51
51
ttl, fee, nonce, nameTtl, clientTtl, extendPointers,
52
52
} ,
53
53
) ;
54
- await printTransaction ( updateTx , json , sdk ) ;
54
+ await printTransaction ( updateTx , json , aeSdk ) ;
55
55
}
56
56
57
57
export async function extendName ( walletPath , name , nameTtl , options ) {
58
58
const {
59
59
ttl, fee, nonce, json,
60
60
} = options ;
61
61
validateName ( name ) ;
62
- const sdk = await initSdkByWalletFile ( walletPath , options ) ;
63
- await ensureNameStatus ( name , sdk , 'CLAIMED' , 'extended' ) ;
64
- const updateTx = await sdk . aensUpdate ( name , { } , {
62
+ const aeSdk = await initSdkByWalletFile ( walletPath , options ) ;
63
+ await ensureNameStatus ( name , aeSdk , 'CLAIMED' , 'extended' ) ;
64
+ const updateTx = await aeSdk . aensUpdate ( name , { } , {
65
65
ttl, fee, nonce, nameTtl, extendPointers : true ,
66
66
} ) ;
67
- await printTransaction ( updateTx , json , sdk ) ;
67
+ await printTransaction ( updateTx , json , aeSdk ) ;
68
68
}
69
69
70
70
export async function transferName ( walletPath , name , address , options ) {
@@ -73,32 +73,32 @@ export async function transferName(walletPath, name, address, options) {
73
73
} = options ;
74
74
if ( ! isAddressValid ( address ) ) throw new CliError ( `Address "${ address } " is not valid` ) ;
75
75
validateName ( name ) ;
76
- const sdk = await initSdkByWalletFile ( walletPath , options ) ;
77
- await ensureNameStatus ( name , sdk , 'CLAIMED' , 'transferred' ) ;
78
- const transferTX = await sdk . aensTransfer ( name , address , { ttl, fee, nonce } ) ;
79
- await printTransaction ( transferTX , json , sdk ) ;
76
+ const aeSdk = await initSdkByWalletFile ( walletPath , options ) ;
77
+ await ensureNameStatus ( name , aeSdk , 'CLAIMED' , 'transferred' ) ;
78
+ const transferTX = await aeSdk . aensTransfer ( name , address , { ttl, fee, nonce } ) ;
79
+ await printTransaction ( transferTX , json , aeSdk ) ;
80
80
}
81
81
82
82
export async function revokeName ( walletPath , name , options ) {
83
83
const {
84
84
ttl, fee, nonce, json,
85
85
} = options ;
86
86
validateName ( name ) ;
87
- const sdk = await initSdkByWalletFile ( walletPath , options ) ;
88
- await ensureNameStatus ( name , sdk , 'CLAIMED' , 'revoked' ) ;
89
- const revokeTx = await sdk . aensRevoke ( name , { ttl, fee, nonce } ) ;
90
- await printTransaction ( revokeTx , json , sdk ) ;
87
+ const aeSdk = await initSdkByWalletFile ( walletPath , options ) ;
88
+ await ensureNameStatus ( name , aeSdk , 'CLAIMED' , 'revoked' ) ;
89
+ const revokeTx = await aeSdk . aensRevoke ( name , { ttl, fee, nonce } ) ;
90
+ await printTransaction ( revokeTx , json , aeSdk ) ;
91
91
}
92
92
93
93
export async function nameBid ( walletPath , name , nameFee , options ) {
94
94
const {
95
95
ttl, fee, nonce, json,
96
96
} = options ;
97
97
validateName ( name ) ;
98
- const sdk = await initSdkByWalletFile ( walletPath , options ) ;
99
- await ensureNameStatus ( name , sdk , 'AUCTION' , 'bidded' ) ;
100
- const nameBidTx = await sdk . aensBid ( name , nameFee , { nonce, ttl, fee } ) ;
101
- await printTransaction ( nameBidTx , json , sdk ) ;
98
+ const aeSdk = await initSdkByWalletFile ( walletPath , options ) ;
99
+ await ensureNameStatus ( name , aeSdk , 'AUCTION' , 'bidded' ) ;
100
+ const nameBidTx = await aeSdk . aensBid ( name , nameFee , { nonce, ttl, fee } ) ;
101
+ await printTransaction ( nameBidTx , json , aeSdk ) ;
102
102
}
103
103
104
104
export async function fullClaim ( walletPath , name , options ) {
@@ -107,10 +107,10 @@ export async function fullClaim(walletPath, name, options) {
107
107
} = options ;
108
108
validateName ( name ) ;
109
109
if ( name . split ( '.' ) [ 0 ] < 13 ) throw new CliError ( 'Full name claiming works only with name longer then 12 symbol (not trigger auction)' ) ;
110
- const sdk = await initSdkByWalletFile ( walletPath , options ) ;
111
- await ensureNameStatus ( name , sdk , 'AVAILABLE' , 'claimed' ) ;
110
+ const aeSdk = await initSdkByWalletFile ( walletPath , options ) ;
111
+ await ensureNameStatus ( name , aeSdk , 'AVAILABLE' , 'claimed' ) ;
112
112
nonce = nonce && + nonce ;
113
- const preclaim = await sdk . aensPreclaim ( name , { nonce, ttl, fee } ) ;
113
+ const preclaim = await aeSdk . aensPreclaim ( name , { nonce, ttl, fee } ) ;
114
114
115
115
nonce = nonce && nonce + 1 ;
116
116
const nameInstance = await preclaim . claim ( {
@@ -119,10 +119,10 @@ export async function fullClaim(walletPath, name, options) {
119
119
120
120
nonce = nonce && nonce + 1 ;
121
121
const updateTx = await nameInstance . update (
122
- { account_pubkey : sdk . address } ,
122
+ { account_pubkey : aeSdk . address } ,
123
123
{
124
124
nonce, ttl, fee, nameTtl, clientTtl,
125
125
} ,
126
126
) ;
127
- await printTransaction ( updateTx , json , sdk ) ;
127
+ await printTransaction ( updateTx , json , aeSdk ) ;
128
128
}
0 commit comments