@leofcoin/contracts 0.1.15 → 0.1.16
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/.size-log.json +17 -0
- package/exports/native-token.js +1 -1
- package/exports/power-token.js +1 -1
- package/package.json +2 -2
package/.size-log.json
CHANGED
|
@@ -110,6 +110,23 @@
|
|
|
110
110
|
"development": 6,
|
|
111
111
|
"total": 8
|
|
112
112
|
}
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"version": "0.1.15",
|
|
116
|
+
"timestamp": "2025-12-25T16:48:50.705Z",
|
|
117
|
+
"size": {
|
|
118
|
+
"bytes": 33746,
|
|
119
|
+
"formatted": "32.96 KB"
|
|
120
|
+
},
|
|
121
|
+
"nodeModules": {
|
|
122
|
+
"bytes": 40109779,
|
|
123
|
+
"formatted": "38.25 MB"
|
|
124
|
+
},
|
|
125
|
+
"dependencies": {
|
|
126
|
+
"production": 2,
|
|
127
|
+
"development": 6,
|
|
128
|
+
"total": 8
|
|
129
|
+
}
|
|
113
130
|
}
|
|
114
131
|
]
|
|
115
132
|
}
|
package/exports/native-token.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class Meta{#creator;#createdAt=BigInt(Date.now());constructor(state){state?(this.#creator=state.creator,this.#createdAt=state.createdAt):(this.#creator=msg.sender,this.#createdAt=BigInt(Date.now()))}get state(){return{creator:this.#creator,createdAt:this.#createdAt}}get creator(){return this.#creator}get createdAt(){return this.#createdAt}}class Roles extends Meta{#roles={OWNER:[],MINT:[],BURN:[]};constructor(state){if(super(state),state?.roles){if(!(state.roles instanceof Object))throw new TypeError("expected roles to be an object");this.#roles={...state.roles}}else this.#grantRole(msg.sender,"OWNER")}get state(){return{...super.state,roles:this.roles}}get roles(){return{...this.#roles}}hasRole(address,role){return!!this.#roles[role]&&this.#roles[role].includes(address)}#grantRole(address,role){if(this.hasRole(address,role))throw new Error(`${role} role already granted for ${address}`);this.#roles[role].push(address)}#revokeRole(address,role){if(!this.hasRole(address,role))throw new Error(`${role} role already revoked for ${address}`);if("OWNER"===role&&1===this.#roles[role].length)throw new Error("atleast one owner is needed!");this.#roles[role].splice(this.#roles[role].indexOf(address))}grantRole(address,role){if(!this.hasRole(address,"OWNER"))throw new Error("Not allowed");this.#grantRole(address,role)}revokeRole(address,role){if(!this.hasRole(address,"OWNER"))throw new Error("Not allowed");this.#revokeRole(address,role)}}class Token extends Roles{#name;#symbol;#holders=0n;#balances={};#approvals={};#decimals=18;#totalSupply=0n;constructor(name,symbol,decimals=18,state){if(!name)throw new Error("name undefined");if(!symbol)throw new Error("symbol undefined");super(state),state?(this.#balances=(balances=>{const _balances={};for(const address in balances)_balances[address]=BigInt(balances[address]);return _balances})(state.balances),this.#approvals=(approvals=>{const _approvals={};for(const owner in approvals){_approvals[owner]={};for(const operator in approvals[owner])_approvals[owner][operator]=BigInt(approvals[owner][operator])}return _approvals})(state.approvals),this.#holders=BigInt(state.holders),this.#totalSupply=BigInt(state.totalSupply)):(this.#name=name,this.#symbol=symbol,this.#decimals=decimals)}get state(){return{...super.state,holders:this.holders,balances:this.balances,approvals:{...this.#approvals},totalSupply:this.totalSupply}}get totalSupply(){return this.#totalSupply}get name(){return this.#name}get symbol(){return this.#symbol}get holders(){return this.#holders}get balances(){return{...this.#balances}}get approvals(){return this.#approvals}get decimals(){return this.#decimals}mint(to,amount){if(!this.hasRole(msg.sender,"MINT"))throw new Error("not allowed");this.#totalSupply=this.#totalSupply+amount,this.#increaseBalance(to,amount)}burn(from,amount){if(!this.hasRole(msg.sender,"BURN"))throw new Error("not allowed");this.#totalSupply=this.#totalSupply-amount,this.#decreaseBalance(from,amount)}#beforeTransfer(from,to,amount){if(!this.#balances[from]||this.#balances[from]<amount)throw new Error("amount exceeds balance")}#updateHolders(address,previousBalance){0n===this.#balances[address]?this.#holders-=1n:0n!==this.#balances[address]&&0n===previousBalance&&(this.#holders+=1n)}#increaseBalance(address,amount){this.#balances[address]||(this.#balances[address]=0n);const previousBalance=this.#balances[address];this.#balances[address]=this.#balances[address]+amount,this.#updateHolders(address,previousBalance)}#decreaseBalance(address,amount){const previousBalance=this.#balances[address];this.#balances[address]=this.#balances[address]-amount,this.#updateHolders(address,previousBalance)}balance(){return this.#balances[msg.sender]}balanceOf(address){return this.#balances[address]}setApproval(operator,amount){const owner=msg.sender;this.#approvals[owner]||(this.#approvals[owner]={}),this.#approvals[owner][operator]=BigInt(amount)}approved(owner,operator,amount){return this.#approvals[owner][operator]===amount}transfer(from,to,amount){amount=BigInt(amount),this.#beforeTransfer(from,to,amount),this.#decreaseBalance(from,amount),this.#increaseBalance(to,amount)}}class Leofcoin extends Token{constructor(state){super("Leofcoin","LFC",18,state)}burn(from,amount){if(this.balanceOf(from)<amount)throw new Error("amount exceeds balance");return super.burn(from,amount)}}export{Leofcoin as default};
|
|
1
|
+
class Meta{#creator;#createdAt=BigInt(Date.now());constructor(state){state?(this.#creator=state.creator,this.#createdAt=state.createdAt):(this.#creator=msg.sender,this.#createdAt=BigInt(Date.now()))}get state(){return{creator:this.#creator,createdAt:this.#createdAt}}get creator(){return this.#creator}get createdAt(){return this.#createdAt}}class Roles extends Meta{#roles={OWNER:[],MINT:[],BURN:[]};constructor(state){if(super(state),state?.roles){if(!(state.roles instanceof Object))throw new TypeError("expected roles to be an object");this.#roles={...state.roles}}else this.#grantRole(msg.sender,"OWNER")}get state(){return{...super.state,roles:this.roles}}get roles(){return{...this.#roles}}hasRole(address,role){return!!this.#roles[role]&&this.#roles[role].includes(address)}#grantRole(address,role){if(this.hasRole(address,role))throw new Error(`${role} role already granted for ${address}`);this.#roles[role].push(address)}#revokeRole(address,role){if(!this.hasRole(address,role))throw new Error(`${role} role already revoked for ${address}`);if("OWNER"===role&&1===this.#roles[role].length)throw new Error("atleast one owner is needed!");this.#roles[role].splice(this.#roles[role].indexOf(address))}grantRole(address,role){if(!this.hasRole(address,"OWNER"))throw new Error("Not allowed");this.#grantRole(address,role)}revokeRole(address,role){if(!this.hasRole(address,"OWNER"))throw new Error("Not allowed");this.#revokeRole(address,role)}}class Token extends Roles{#name;#symbol;#holders=0n;#balances={};#approvals={};#decimals=18;#totalSupply=0n;constructor(name,symbol,decimals=18,state){if(!name)throw new Error("name undefined");if(!symbol)throw new Error("symbol undefined");super(state),state?(this.#balances=(balances=>{const _balances={};for(const address in balances)_balances[address]=BigInt(balances[address]);return _balances})(state.balances),this.#approvals=(approvals=>{const _approvals={};for(const owner in approvals){_approvals[owner]={};for(const operator in approvals[owner])_approvals[owner][operator]=BigInt(approvals[owner][operator])}return _approvals})(state.approvals),this.#holders=BigInt(state.holders),this.#totalSupply=BigInt(state.totalSupply)):(this.#name=name,this.#symbol=symbol,this.#decimals=decimals)}get state(){return{...super.state,holders:this.holders,balances:this.balances,approvals:{...this.#approvals},totalSupply:this.totalSupply}}get totalSupply(){return this.#totalSupply}get name(){return this.#name}get symbol(){return this.#symbol}get holders(){return this.#holders}get balances(){return{...this.#balances}}get approvals(){return this.#approvals}get decimals(){return this.#decimals}mint(to,amount){if(!this.hasRole(msg.sender,"MINT"))throw new Error("not allowed");this.#totalSupply=this.#totalSupply+amount,this.#increaseBalance(to,amount)}burn(from,amount){if(!this.hasRole(msg.sender,"BURN"))throw new Error("not allowed");this.#totalSupply=this.#totalSupply-amount,this.#beforeTransfer(from,from,amount),this.#decreaseBalance(from,amount)}#beforeTransfer(from,to,amount){if(!from)throw new Error("address undefined");if(amount<0n)throw new Error("amount must be positive");if(!this.#balances[from]||this.#balances[from]<amount)throw new Error("amount exceeds balance")}#updateHolders(address,previousBalance){0n===this.#balances[address]?this.#holders-=1n:0n!==this.#balances[address]&&0n===previousBalance&&(this.#holders+=1n)}#increaseBalance(address,amount){this.#balances[address]||(this.#balances[address]=0n);const previousBalance=this.#balances[address];this.#balances[address]=this.#balances[address]+amount,this.#updateHolders(address,previousBalance)}#decreaseBalance(address,amount){const previousBalance=this.#balances[address];this.#balances[address]=this.#balances[address]-amount,this.#updateHolders(address,previousBalance)}balance(){return this.#balances[msg.sender]}balanceOf(address){return this.#balances[address]}setApproval(operator,amount){const owner=msg.sender;this.#approvals[owner]||(this.#approvals[owner]={}),this.#approvals[owner][operator]=BigInt(amount)}approved(owner,operator,amount){return this.#approvals[owner][operator]===amount}transfer(from,to,amount){amount=BigInt(amount),this.#beforeTransfer(from,to,amount),this.#decreaseBalance(from,amount),this.#increaseBalance(to,amount)}}class Leofcoin extends Token{constructor(state){super("Leofcoin","LFC",18,state)}burn(from,amount){if(this.balanceOf(from)<amount)throw new Error("amount exceeds balance");return super.burn(from,amount)}}export{Leofcoin as default};
|
package/exports/power-token.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class Meta{#creator;#createdAt=BigInt(Date.now());constructor(state){state?(this.#creator=state.creator,this.#createdAt=state.createdAt):(this.#creator=msg.sender,this.#createdAt=BigInt(Date.now()))}get state(){return{creator:this.#creator,createdAt:this.#createdAt}}get creator(){return this.#creator}get createdAt(){return this.#createdAt}}class Roles extends Meta{#roles={OWNER:[],MINT:[],BURN:[]};constructor(state){if(super(state),state?.roles){if(!(state.roles instanceof Object))throw new TypeError("expected roles to be an object");this.#roles={...state.roles}}else this.#grantRole(msg.sender,"OWNER")}get state(){return{...super.state,roles:this.roles}}get roles(){return{...this.#roles}}hasRole(address,role){return!!this.#roles[role]&&this.#roles[role].includes(address)}#grantRole(address,role){if(this.hasRole(address,role))throw new Error(`${role} role already granted for ${address}`);this.#roles[role].push(address)}#revokeRole(address,role){if(!this.hasRole(address,role))throw new Error(`${role} role already revoked for ${address}`);if("OWNER"===role&&1===this.#roles[role].length)throw new Error("atleast one owner is needed!");this.#roles[role].splice(this.#roles[role].indexOf(address))}grantRole(address,role){if(!this.hasRole(address,"OWNER"))throw new Error("Not allowed");this.#grantRole(address,role)}revokeRole(address,role){if(!this.hasRole(address,"OWNER"))throw new Error("Not allowed");this.#revokeRole(address,role)}}class Token extends Roles{#name;#symbol;#holders=0n;#balances={};#approvals={};#decimals=18;#totalSupply=0n;constructor(name,symbol,decimals=18,state){if(!name)throw new Error("name undefined");if(!symbol)throw new Error("symbol undefined");super(state),state?(this.#balances=(balances=>{const _balances={};for(const address in balances)_balances[address]=BigInt(balances[address]);return _balances})(state.balances),this.#approvals=(approvals=>{const _approvals={};for(const owner in approvals){_approvals[owner]={};for(const operator in approvals[owner])_approvals[owner][operator]=BigInt(approvals[owner][operator])}return _approvals})(state.approvals),this.#holders=BigInt(state.holders),this.#totalSupply=BigInt(state.totalSupply)):(this.#name=name,this.#symbol=symbol,this.#decimals=decimals)}get state(){return{...super.state,holders:this.holders,balances:this.balances,approvals:{...this.#approvals},totalSupply:this.totalSupply}}get totalSupply(){return this.#totalSupply}get name(){return this.#name}get symbol(){return this.#symbol}get holders(){return this.#holders}get balances(){return{...this.#balances}}get approvals(){return this.#approvals}get decimals(){return this.#decimals}mint(to,amount){if(!this.hasRole(msg.sender,"MINT"))throw new Error("not allowed");this.#totalSupply=this.#totalSupply+amount,this.#increaseBalance(to,amount)}burn(from,amount){if(!this.hasRole(msg.sender,"BURN"))throw new Error("not allowed");this.#totalSupply=this.#totalSupply-amount,this.#decreaseBalance(from,amount)}#beforeTransfer(from,to,amount){if(!this.#balances[from]||this.#balances[from]<amount)throw new Error("amount exceeds balance")}#updateHolders(address,previousBalance){0n===this.#balances[address]?this.#holders-=1n:0n!==this.#balances[address]&&0n===previousBalance&&(this.#holders+=1n)}#increaseBalance(address,amount){this.#balances[address]||(this.#balances[address]=0n);const previousBalance=this.#balances[address];this.#balances[address]=this.#balances[address]+amount,this.#updateHolders(address,previousBalance)}#decreaseBalance(address,amount){const previousBalance=this.#balances[address];this.#balances[address]=this.#balances[address]-amount,this.#updateHolders(address,previousBalance)}balance(){return this.#balances[msg.sender]}balanceOf(address){return this.#balances[address]}setApproval(operator,amount){const owner=msg.sender;this.#approvals[owner]||(this.#approvals[owner]={}),this.#approvals[owner][operator]=BigInt(amount)}approved(owner,operator,amount){return this.#approvals[owner][operator]===amount}transfer(from,to,amount){amount=BigInt(amount),this.#beforeTransfer(from,to,amount),this.#decreaseBalance(from,amount),this.#increaseBalance(to,amount)}}class Power extends Token{constructor(state){super("Power","PWR",18,state)}}export{Power as default};
|
|
1
|
+
class Meta{#creator;#createdAt=BigInt(Date.now());constructor(state){state?(this.#creator=state.creator,this.#createdAt=state.createdAt):(this.#creator=msg.sender,this.#createdAt=BigInt(Date.now()))}get state(){return{creator:this.#creator,createdAt:this.#createdAt}}get creator(){return this.#creator}get createdAt(){return this.#createdAt}}class Roles extends Meta{#roles={OWNER:[],MINT:[],BURN:[]};constructor(state){if(super(state),state?.roles){if(!(state.roles instanceof Object))throw new TypeError("expected roles to be an object");this.#roles={...state.roles}}else this.#grantRole(msg.sender,"OWNER")}get state(){return{...super.state,roles:this.roles}}get roles(){return{...this.#roles}}hasRole(address,role){return!!this.#roles[role]&&this.#roles[role].includes(address)}#grantRole(address,role){if(this.hasRole(address,role))throw new Error(`${role} role already granted for ${address}`);this.#roles[role].push(address)}#revokeRole(address,role){if(!this.hasRole(address,role))throw new Error(`${role} role already revoked for ${address}`);if("OWNER"===role&&1===this.#roles[role].length)throw new Error("atleast one owner is needed!");this.#roles[role].splice(this.#roles[role].indexOf(address))}grantRole(address,role){if(!this.hasRole(address,"OWNER"))throw new Error("Not allowed");this.#grantRole(address,role)}revokeRole(address,role){if(!this.hasRole(address,"OWNER"))throw new Error("Not allowed");this.#revokeRole(address,role)}}class Token extends Roles{#name;#symbol;#holders=0n;#balances={};#approvals={};#decimals=18;#totalSupply=0n;constructor(name,symbol,decimals=18,state){if(!name)throw new Error("name undefined");if(!symbol)throw new Error("symbol undefined");super(state),state?(this.#balances=(balances=>{const _balances={};for(const address in balances)_balances[address]=BigInt(balances[address]);return _balances})(state.balances),this.#approvals=(approvals=>{const _approvals={};for(const owner in approvals){_approvals[owner]={};for(const operator in approvals[owner])_approvals[owner][operator]=BigInt(approvals[owner][operator])}return _approvals})(state.approvals),this.#holders=BigInt(state.holders),this.#totalSupply=BigInt(state.totalSupply)):(this.#name=name,this.#symbol=symbol,this.#decimals=decimals)}get state(){return{...super.state,holders:this.holders,balances:this.balances,approvals:{...this.#approvals},totalSupply:this.totalSupply}}get totalSupply(){return this.#totalSupply}get name(){return this.#name}get symbol(){return this.#symbol}get holders(){return this.#holders}get balances(){return{...this.#balances}}get approvals(){return this.#approvals}get decimals(){return this.#decimals}mint(to,amount){if(!this.hasRole(msg.sender,"MINT"))throw new Error("not allowed");this.#totalSupply=this.#totalSupply+amount,this.#increaseBalance(to,amount)}burn(from,amount){if(!this.hasRole(msg.sender,"BURN"))throw new Error("not allowed");this.#totalSupply=this.#totalSupply-amount,this.#beforeTransfer(from,from,amount),this.#decreaseBalance(from,amount)}#beforeTransfer(from,to,amount){if(!from)throw new Error("address undefined");if(amount<0n)throw new Error("amount must be positive");if(!this.#balances[from]||this.#balances[from]<amount)throw new Error("amount exceeds balance")}#updateHolders(address,previousBalance){0n===this.#balances[address]?this.#holders-=1n:0n!==this.#balances[address]&&0n===previousBalance&&(this.#holders+=1n)}#increaseBalance(address,amount){this.#balances[address]||(this.#balances[address]=0n);const previousBalance=this.#balances[address];this.#balances[address]=this.#balances[address]+amount,this.#updateHolders(address,previousBalance)}#decreaseBalance(address,amount){const previousBalance=this.#balances[address];this.#balances[address]=this.#balances[address]-amount,this.#updateHolders(address,previousBalance)}balance(){return this.#balances[msg.sender]}balanceOf(address){return this.#balances[address]}setApproval(operator,amount){const owner=msg.sender;this.#approvals[owner]||(this.#approvals[owner]={}),this.#approvals[owner][operator]=BigInt(amount)}approved(owner,operator,amount){return this.#approvals[owner][operator]===amount}transfer(from,to,amount){amount=BigInt(amount),this.#beforeTransfer(from,to,amount),this.#decreaseBalance(from,amount),this.#increaseBalance(to,amount)}}class Power extends Token{constructor(state){super("Power","PWR",18,state)}}export{Power as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/contracts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/leofcoin/contracts#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@leofcoin/standards": "^0.3.
|
|
31
|
+
"@leofcoin/standards": "^0.3.6",
|
|
32
32
|
"lucky-numbers": "^1.2.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|