@leofcoin/contracts 0.1.3 → 0.1.4
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/exports/name-service.d.ts +1 -1
- package/exports/name-service.js +1 -1
- package/package.json +1 -1
- package/src/name-service.ts +2 -2
- package/src/validators.ts +3 -3
package/exports/name-service.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class NameService{#name="ArtOnlineNameService";#owner;#price=0;#registry;#currency;get name(){return this.#name}get registry(){return{...this.#registry}}get state(){return{owner:this.#owner,registry:this.#registry,currency:this.#currency,price:this.#price}}constructor(factoryAddress,currency,validatorAddress,price,state){state?(this.#owner=state.owner,this.#registry=state.registry,this.#currency=state.currency,this.#price=state.price):(this.#owner=msg.sender,this.#price=price,this.#registry.ArtOnlineContractFactory={owner:msg.sender,address:factoryAddress},this.#registry.ArtOnlineToken={owner:msg.sender,address:currency},this.#registry.ArtOnlineValidators={owner:msg.sender,address:validatorAddress},this.#currency=currency)}changeOwner(owner){if(msg.sender!==this.#owner)throw new Error("no owner");this.#owner=owner}changePrice(price){if(msg.sender!==this.#owner)throw new Error("no owner");this.#price=price}changeCurrency(currency){if(msg.sender!==this.#owner)throw new Error("no owner");this.#currency=currency}async purchaseName(name,address){if(await msg.call(this.#currency,"balanceOf",[msg.sender])<this.#price)throw new Error("price exceeds balance");try{await msg.call(this.#currency,"transfer",[msg.sender,this.#owner,this.#price])}catch(error){throw error}this.#registry[name]={owner:msg.sender,address:address}}lookup(name){return this.#registry[name]}transferOwnership(name,to){if(msg.sender!==this.#registry[name].owner)throw new Error("not a owner");this.#registry[name].owner=to}changeAddress(name,address){if(msg.sender!==this.#registry[name].owner)throw new Error("not a owner");this.#registry[name].address=address}}export{NameService as default};
|
|
1
|
+
class NameService{#name="ArtOnlineNameService";#owner;#price=0;#registry={};#currency;get name(){return this.#name}get registry(){return{...this.#registry}}get state(){return{owner:this.#owner,registry:this.#registry,currency:this.#currency,price:this.#price}}constructor(factoryAddress,currency,validatorAddress,price,state){state?(this.#owner=state.owner,this.#registry=state.registry,this.#currency=state.currency,this.#price=state.price):(this.#owner=msg.sender,this.#price=price,this.#registry.ArtOnlineContractFactory={owner:msg.sender,address:factoryAddress},this.#registry.ArtOnlineToken={owner:msg.sender,address:currency},this.#registry.ArtOnlineValidators={owner:msg.sender,address:validatorAddress},this.#currency=currency)}changeOwner(owner){if(msg.sender!==this.#owner)throw new Error("no owner");this.#owner=owner}changePrice(price){if(msg.sender!==this.#owner)throw new Error("no owner");this.#price=price}changeCurrency(currency){if(msg.sender!==this.#owner)throw new Error("no owner");this.#currency=currency}async purchaseName(name,address){if(await msg.call(this.#currency,"balanceOf",[msg.sender])<this.#price)throw new Error("price exceeds balance");try{await msg.call(this.#currency,"transfer",[msg.sender,this.#owner,this.#price])}catch(error){throw error}this.#registry[name]={owner:msg.sender,address:address}}lookup(name){return this.#registry[name]}transferOwnership(name,to){if(msg.sender!==this.#registry[name].owner)throw new Error("not a owner");this.#registry[name].owner=to}changeAddress(name,address){if(msg.sender!==this.#registry[name].owner)throw new Error("not a owner");this.#registry[name].address=address}}export{NameService as default};
|
package/package.json
CHANGED
package/src/name-service.ts
CHANGED
package/src/validators.ts
CHANGED
|
@@ -16,9 +16,9 @@ export default class Validators extends Roles {
|
|
|
16
16
|
*/
|
|
17
17
|
#validators = {}
|
|
18
18
|
|
|
19
|
-
#currency
|
|
19
|
+
#currency: address
|
|
20
20
|
|
|
21
|
-
#minimumBalance
|
|
21
|
+
#minimumBalance: BigNumberish
|
|
22
22
|
|
|
23
23
|
get state() {
|
|
24
24
|
return {
|
|
@@ -31,7 +31,7 @@ export default class Validators extends Roles {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
constructor(tokenAddress, state) {
|
|
34
|
+
constructor(tokenAddress: address, state) {
|
|
35
35
|
super(state?.roles)
|
|
36
36
|
if (state) {
|
|
37
37
|
this.#minimumBalance = state.minimumBalance
|