@@ -99,7 +99,7 @@ export class BNSClient extends Client {
9999 const tx = this . createTransaction ( {
100100 method : {
101101 name : "namespace-reveal" ,
102- args : [ `" ${ namespace } " ` , `" ${ salt } " ` , ...priceFuncAsArgs , `u${ renewalRule } ` , `'${ nameImporter } ` ]
102+ args : [ `0x ${ this . toHexString ( namespace ) } ` , `0x ${ this . toHexString ( salt ) } ` , ...priceFuncAsArgs , `u${ renewalRule } ` , `'${ nameImporter } ` ]
103103 }
104104 } ) ;
105105 await tx . sign ( params . sender ) ;
@@ -109,18 +109,18 @@ export class BNSClient extends Client {
109109
110110 // (name-import (namespace (buff 20))
111111 // (name (buff 16))
112- // (zonefile-content (buff 40960 )))
112+ // (zonefile-hash (buff 20 )))
113113 async nameImport ( namespace : string ,
114114 name : string ,
115115 beneficiary : string ,
116- zonefileContent : string ,
116+ zonefileHash : string ,
117117 params : {
118118 sender : string
119119 } ) : Promise < Receipt > {
120120 const tx = this . createTransaction ( {
121121 method : {
122122 name : "name-import" ,
123- args : [ `" ${ namespace } " ` , `" ${ name } " ` , `'${ beneficiary } ` , `" ${ zonefileContent } " ` ]
123+ args : [ `0x ${ this . toHexString ( namespace ) } ` , `0x ${ this . toHexString ( name ) } ` , `'${ beneficiary } ` , `0x ${ this . toHexString ( zonefileHash ) } ` ]
124124 }
125125 } ) ;
126126 await tx . sign ( params . sender ) ;
@@ -135,7 +135,7 @@ export class BNSClient extends Client {
135135 const tx = this . createTransaction ( {
136136 method : {
137137 name : "namespace-ready" ,
138- args : [ `" ${ namespace } " ` ]
138+ args : [ `0x ${ this . toHexString ( namespace ) } ` ]
139139 }
140140 } ) ;
141141 await tx . sign ( params . sender ) ;
@@ -170,18 +170,18 @@ export class BNSClient extends Client {
170170 // (name-register (namespace (buff 20))
171171 // (name (buff 16))
172172 // (salt (buff 20))
173- // (zonefile-content (buff 40960 )))
173+ // (zonefile-hash (buff 20 )))
174174 async nameRegister ( namespace : string ,
175175 name : string ,
176176 salt : string ,
177- zonefileContent : string ,
177+ zonefileHash : string ,
178178 params : {
179179 sender : string
180180 } ) : Promise < Receipt > {
181181 const tx = this . createTransaction ( {
182182 method : {
183183 name : "name-register" ,
184- args : [ `" ${ namespace } " ` , `" ${ name } " ` , `" ${ salt } " ` , `" ${ zonefileContent } " ` ]
184+ args : [ `0x ${ this . toHexString ( namespace ) } ` , `0x ${ this . toHexString ( name ) } ` , `0x ${ this . toHexString ( salt ) } ` , `0x ${ this . toHexString ( zonefileHash ) } ` ]
185185 }
186186 } ) ;
187187 await tx . sign ( params . sender ) ;
@@ -191,17 +191,17 @@ export class BNSClient extends Client {
191191
192192 // (name-update (namespace (buff 20))
193193 // (name (buff 16))
194- // (zonefile-content (buff 40960 )))
194+ // (zonefile-hash (buff 20 )))
195195 async nameUpdate ( namespace : string ,
196196 name : string ,
197- zonefileContent : string ,
197+ zonefileHash : string ,
198198 params : {
199199 sender : string
200200 } ) : Promise < Receipt > {
201201 const tx = this . createTransaction ( {
202202 method : {
203203 name : "name-update" ,
204- args : [ `" ${ namespace } " ` , `" ${ name } " ` , `" ${ zonefileContent } " ` ]
204+ args : [ `0x ${ this . toHexString ( namespace ) } ` , `0x ${ this . toHexString ( name ) } ` , `0x ${ this . toHexString ( zonefileHash ) } ` ]
205205 }
206206 } ) ;
207207 await tx . sign ( params . sender ) ;
@@ -212,16 +212,16 @@ export class BNSClient extends Client {
212212 // (name-transfer (namespace (buff 20))
213213 // (name (buff 16))
214214 // (new-owner principal)
215- // (zonefile-content (optional (buff 40960 ))))
215+ // (zonefile-hash (optional (buff 20 ))))
216216 async nameTransfer ( namespace : string ,
217217 name : string ,
218218 newOwner : string ,
219- zonefileContent : string | null ,
219+ zonefileHash : string | null ,
220220 params : {
221221 sender : string
222222 } ) : Promise < Receipt > {
223- const args = [ `" ${ namespace } " ` , `" ${ name } " ` , `'${ newOwner } ` ] ;
224- args . push ( zonefileContent === null ? "none" : `(some\ " ${ zonefileContent } " )` ) ;
223+ const args = [ `0x ${ this . toHexString ( namespace ) } ` , `0x ${ this . toHexString ( name ) } ` , `'${ newOwner } ` ] ;
224+ args . push ( zonefileHash === null ? "none" : `(some\ 0x ${ this . toHexString ( zonefileHash ) } )` ) ;
225225
226226 const tx = this . createTransaction ( {
227227 method : {
@@ -244,7 +244,7 @@ export class BNSClient extends Client {
244244 const tx = this . createTransaction ( {
245245 method : {
246246 name : "name-revoke" ,
247- args : [ `" ${ namespace } " ` , `" ${ name } " ` ]
247+ args : [ `0x ${ this . toHexString ( namespace ) } ` , `0x ${ this . toHexString ( name ) } ` ]
248248 }
249249 } ) ;
250250 await tx . sign ( params . sender ) ;
@@ -256,18 +256,18 @@ export class BNSClient extends Client {
256256 // (name (buff 16))
257257 // (stx-to-burn uint)
258258 // (new-owner (optional principal))
259- // (zonefile-content (optional (buff 40960 ))))
259+ // (zonefile-hash (optional (buff 20 ))))
260260 async nameRenewal ( namespace : string ,
261261 name : string ,
262262 STX : number ,
263263 newOwner : null | string ,
264- zonefileContent : null | string ,
264+ zonefileHash : null | string ,
265265 params : {
266266 sender : string
267267 } ) : Promise < Receipt > {
268- const args = [ `" ${ namespace } " ` , `" ${ name } " ` , `u${ STX } ` ] ;
268+ const args = [ `0x ${ this . toHexString ( namespace ) } ` , `0x ${ this . toHexString ( name ) } ` , `u${ STX } ` ] ;
269269 args . push ( newOwner === null ? "none" : `(some\ '${ newOwner } )` ) ;
270- args . push ( zonefileContent === null ? "none" : `(some\ " ${ zonefileContent } " )` ) ;
270+ args . push ( zonefileHash === null ? "none" : `(some\ 0x ${ this . toHexString ( zonefileHash ) } )` ) ;
271271
272272 const tx = this . createTransaction ( {
273273 method : {
@@ -290,7 +290,7 @@ export class BNSClient extends Client {
290290 const tx = this . createTransaction ( {
291291 method : {
292292 name : "name-resolve" ,
293- args : [ `" ${ namespace } " ` , `" ${ name } " ` ]
293+ args : [ `0x ${ this . toHexString ( namespace ) } ` , `0x ${ this . toHexString ( name ) } ` ]
294294 }
295295 } ) ;
296296 await tx . sign ( params . sender ) ;
@@ -302,7 +302,7 @@ export class BNSClient extends Client {
302302 // (name (buff 16))
303303 async canNameBeRegistered ( namespace : string ,
304304 name : string ) : Promise < Receipt > {
305- const args = [ `" ${ namespace } " ` , `" ${ name } " ` ] ;
305+ const args = [ `0x ${ this . toHexString ( namespace ) } ` , `0x ${ this . toHexString ( name ) } ` ] ;
306306 const query = this . createQuery ( {
307307 atChaintip : false ,
308308 method : {
@@ -314,16 +314,50 @@ export class BNSClient extends Client {
314314 return res ;
315315 }
316316
317+ // (get-name-price (namespace (buff 20))
318+ // (name (buff 16))
319+ async getNamePrice ( namespace : string ,
320+ name : string ) : Promise < Receipt > {
321+ const args = [ `0x${ this . toHexString ( namespace ) } ` , `0x${ this . toHexString ( name ) } ` ] ;
322+ const query = this . createQuery ( {
323+ atChaintip : false ,
324+ method : {
325+ name : "get-name-price" ,
326+ args : args
327+ }
328+ } ) ;
329+ const res = await this . submitQuery ( query ) ;
330+ return res ;
331+ }
332+
333+ // (get-namespace-price (namespace (buff 20))
334+ async getNamespacePrice ( namespace : string ) : Promise < Receipt > {
335+ const args = [ `0x${ this . toHexString ( namespace ) } ` ] ;
336+ const query = this . createQuery ( {
337+ atChaintip : false ,
338+ method : {
339+ name : "get-namespace-price" ,
340+ args : args
341+ }
342+ } ) ;
343+ const res = await this . submitQuery ( query ) ;
344+ return res ;
345+ }
346+
317347 async mineBlocks ( blocks : number ) {
318348 for ( let index = 0 ; index < blocks ; index ++ ) {
319349 const query = this . createQuery ( {
320350 atChaintip : false ,
321351 method : {
322- name : "compute -namespace-price? " ,
352+ name : "get -namespace-price" ,
323353 args : [ '0x0000' ]
324354 }
325355 } ) ;
326356 const res = await this . submitQuery ( query ) ;
327357 }
328358 }
359+
360+ toHexString ( input : String ) : String {
361+ return Buffer . from ( input ) . toString ( 'hex' ) ;
362+ }
329363}
0 commit comments