@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.
@@ -1,5 +1,5 @@
1
1
  type registry = {
2
- name: {
2
+ name?: {
3
3
  address: address;
4
4
  owner: address;
5
5
  };
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/contracts",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,5 +1,5 @@
1
1
  type registry = {
2
- name: {
2
+ name?: {
3
3
  address: address,
4
4
  owner: address
5
5
  }
@@ -21,7 +21,7 @@ export default class NameService {
21
21
  /**
22
22
  * Object => string
23
23
  */
24
- #registry: registry
24
+ #registry: registry = {}
25
25
 
26
26
  /**
27
27
  * => string
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