gamegold 5.4.0 → 5.4.1
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/lib/gamegold-worker.js +2 -2
- package/lib/gamegold.js +2 -2
- package/package.json +1 -1
package/lib/gamegold-worker.js
CHANGED
|
@@ -196,7 +196,7 @@ var r=i(126),a=r.Buffer;function s(e,t){for(var i in e)t[i]=e[i]}function n(e,t,
|
|
|
196
196
|
* pkg.js - package constants
|
|
197
197
|
* Copyright (c) 2019-2022, Bookman Software (MIT License).
|
|
198
198
|
* https://github.com/bookmansoft/gamegold
|
|
199
|
-
*/t.protocol="vallnet",t.version="v5.4.
|
|
199
|
+
*/t.protocol="vallnet",t.version="v5.4.1",t.url="https://github.com/bookmansoft/gamegold"},function(e,t,i){"use strict";
|
|
200
200
|
/*!
|
|
201
201
|
* common.js - p2p constants for vallnet
|
|
202
202
|
* Copyright (c) 2019-2022, Bookman Software (MIT License).
|
|
@@ -424,7 +424,7 @@ function r(e){let t=null;var i=r.list[e.contract.options.type];return i?new(t=i.
|
|
|
424
424
|
*
|
|
425
425
|
* @note 为了让打包程序正常工作,没有使用自动化方案来引入类文件
|
|
426
426
|
*/
|
|
427
|
-
const r=i(5).ContractType;e.exports=function(e){if(!e)return i(188);switch(e.oper){case r.cpRegister:return i(192);case r.cpChange:return i(194);case r.coinbase:return i(195);case r.contractPromise:return i(196);case r.scRegister:return i(581);case r.scUpdate:return i(199);case r.scState:return i(200);case r.scRun:return i(201);case r.scNotify:return i(207);case r.propFound:return i(208);case r.vote:return i(209);case r.propSale:return i(210);case r.notify:return i(211);case r.contractCreate:return i(212);case r.contractExecute:return i(213);case r.erIssue:return i(214);case r.erAbolish:return i(215);case r.enchanceCp:return i(216);default:try{return i(582)("./"+e.oper)}catch(e){return i(14)}}}},function(e,t,i){var r=i(14);const a=i(19).nestingExtentCodes,s=i(117);e.exports=class extends r{async insert(){var e=this.getOpt();for(let i=0;i<e.tx.outputs.length;i++){var t=""+e.hash+i;e.env.middleHashMem.has(t)||this.setOptIndex(e,i)&&(await s(e).insert(),e.env.middleHashMem.add(t))}}async erase(){var e=this.getOpt();for(let t=0;t<e.tx.outputs.length;t++)e.env.middleHashMem.delete(""+e.hash+t),this.setOptIndex(e,t)&&await s(e).erase()}async confirm(){var e=this.getOpt();for(let i=0;i<e.tx.outputs.length;i++){var t=""+e.hash+i;e.env.middleHashChain.has(t)||this.setOptIndex(e,i)&&(await s(e).confirm(),e.env.middleHashChain.add(t))}}async unconfirm(){var e=this.getOpt();for(let t=0;t<e.tx.outputs.length;t++)e.env.middleHashChain.delete(""+e.hash+t),this.setOptIndex(e,t)&&await s(e).unconfirm()}async verify(){var e=this.getOpt();for(let i=0;i<e.tx.outputs.length;i++)if(this.setOptIndex(e,i)){var t=await s(e).verify();if(1!=t)return t}return!0}getOpt(){return{env:this.options.env,tx:this.options.tx,block:this.options.block,height:this.options.coinbaseHeight,hash:this.options.hash}}setOptIndex(e,t){return e.i=t,e.output=e.tx.outputs[t],e.type=e.output.getReturnType(),e.data=e.output.getReturnData(a),!!e.data}}},function(e,t,i){const{ContractEnvType:r,PropStatus:a}=i(5);var s=i(52);const n=i(7),o=i(148);e.exports=class extends s{async confirm(){var{env:e,i:t,output:i,data:s,hash:n,block:o,tx:c}=this.options,u=await e.propList.getVp(s.pid);!u||u.current.hash==n&&u.current.index==t?(s.current={hash:n,index:t,address:i.getAddress().toString()},s.height=0<e.curHeight?e.curHeight+1:0,s.pst=a.Ready,s.gold=i.value,await e.propList.setVp(s,c),e.mode==r.Block&&(i={pid:s.pid,oid:s.oid,cid:s.cid,dst:s.current.address,time:o.time,height:s.height,value:s.gold},e.node.transmit("prop.create",i))):e.logger.warning("PropCreate.conflict",s.pid,", height: ",o?o.height:0,"mode: ",e.mode,n,t,u.current.hash,u.current.index)}async unconfirm(){var e,{env:t,i:i,data:e,hash:r}=this.options;(e=await t.propList.getVp(e.pid))&&e.current.hash==r&&e.current.index==i&&await t.propList.delVp(e)}async verify(){var{env:e,output:t,data:i}=this.options;if(!o.unittest){var r=e.cpList.getItem(i.cid);if(!r||r.current.address!=t.getAddress().toString())return"PropCreate.errorAddress"}return t.value<n.MINPROPVALUE?"PropCreate.MINPROPVALUE":!e.network.tokenReg.test(i.pid)||"PropCreate.invalidPid"}}},function(e,t,i){const r=i(5).ContractEnvType;i=i(52);e.exports=class extends i{async confirm(){var{env:e,
|
|
427
|
+
const r=i(5).ContractType;e.exports=function(e){if(!e)return i(188);switch(e.oper){case r.cpRegister:return i(192);case r.cpChange:return i(194);case r.coinbase:return i(195);case r.contractPromise:return i(196);case r.scRegister:return i(581);case r.scUpdate:return i(199);case r.scState:return i(200);case r.scRun:return i(201);case r.scNotify:return i(207);case r.propFound:return i(208);case r.vote:return i(209);case r.propSale:return i(210);case r.notify:return i(211);case r.contractCreate:return i(212);case r.contractExecute:return i(213);case r.erIssue:return i(214);case r.erAbolish:return i(215);case r.enchanceCp:return i(216);default:try{return i(582)("./"+e.oper)}catch(e){return i(14)}}}},function(e,t,i){var r=i(14);const a=i(19).nestingExtentCodes,s=i(117);e.exports=class extends r{async insert(){var e=this.getOpt();for(let i=0;i<e.tx.outputs.length;i++){var t=""+e.hash+i;e.env.middleHashMem.has(t)||this.setOptIndex(e,i)&&(await s(e).insert(),e.env.middleHashMem.add(t))}}async erase(){var e=this.getOpt();for(let t=0;t<e.tx.outputs.length;t++)e.env.middleHashMem.delete(""+e.hash+t),this.setOptIndex(e,t)&&await s(e).erase()}async confirm(){var e=this.getOpt();for(let i=0;i<e.tx.outputs.length;i++){var t=""+e.hash+i;e.env.middleHashChain.has(t)||this.setOptIndex(e,i)&&(await s(e).confirm(),e.env.middleHashChain.add(t))}}async unconfirm(){var e=this.getOpt();for(let t=0;t<e.tx.outputs.length;t++)e.env.middleHashChain.delete(""+e.hash+t),this.setOptIndex(e,t)&&await s(e).unconfirm()}async verify(){var e=this.getOpt();for(let i=0;i<e.tx.outputs.length;i++)if(this.setOptIndex(e,i)){var t=await s(e).verify();if(1!=t)return t}return!0}getOpt(){return{env:this.options.env,tx:this.options.tx,block:this.options.block,height:this.options.coinbaseHeight,hash:this.options.hash}}setOptIndex(e,t){return e.i=t,e.output=e.tx.outputs[t],e.type=e.output.getReturnType(),e.data=e.output.getReturnData(a),!!e.data}}},function(e,t,i){const{ContractEnvType:r,PropStatus:a}=i(5);var s=i(52);const n=i(7),o=i(148);e.exports=class extends s{async confirm(){var{env:e,i:t,output:i,data:s,hash:n,block:o,tx:c}=this.options,u=await e.propList.getVp(s.pid);!u||u.current.hash==n&&u.current.index==t?(s.current={hash:n,index:t,address:i.getAddress().toString()},s.height=0<e.curHeight?e.curHeight+1:0,s.pst=a.Ready,s.gold=i.value,await e.propList.setVp(s,c),e.mode==r.Block&&(i={pid:s.pid,oid:s.oid,cid:s.cid,dst:s.current.address,time:o.time,height:s.height,value:s.gold},e.node.transmit("prop.create",i))):e.logger.warning("PropCreate.conflict",s.pid,", height: ",o?o.height:0,"mode: ",e.mode,n,t,u.current.hash,u.current.index)}async unconfirm(){var e,{env:t,i:i,data:e,hash:r}=this.options;(e=await t.propList.getVp(e.pid))&&e.current.hash==r&&e.current.index==i&&await t.propList.delVp(e)}async verify(){var{env:e,output:t,data:i}=this.options;if(!o.unittest){var r=e.cpList.getItem(i.cid);if(!r||r.current.address!=t.getAddress().toString())return"PropCreate.errorAddress"}return t.value<n.MINPROPVALUE?"PropCreate.MINPROPVALUE":!e.network.tokenReg.test(i.pid)||"PropCreate.invalidPid"}}},function(e,t,i){const r=i(5).ContractEnvType;i=i(52);e.exports=class extends i{async confirm(){var{env:e,i:t,output:i,data:a,hash:s,block:n}=this.options;e.mode==r.Block&&(a={data:a,height:0<e.curHeight?e.curHeight+1:0,gold:i.value,time:n.time,current:{hash:s,index:t,address:i.getAddress().toString()}},e.node.transmit("attach.confirm",a))}async unconfirm(){var{env:e,i:t,output:i,data:a,hash:s,block:n}=this.options;e.mode==r.Block&&(a={data:a,height:0<e.curHeight?e.curHeight+1:0,gold:i.value,time:n.time,current:{hash:s,index:t,address:i.getAddress().toString()}},e.node.transmit("attach.unconfirm",a))}async verify(){return!0}}},function(e,t,i){const r=i(0),a=i(19).opcodes,s=i(38).broadcast,n=i(132).vpItem;var o=i(52);const{ContractEnvType:c,PropStatus:u}=i(5);e.exports=class extends o{async confirm(){let{env:e,i:t,output:i,data:r,hash:o,tx:h,block:l}=this.options;if(e.mode==c.Wallet){var p=await e.propList.getVp(r.pid);if(p&&(p.current.hash!=r.prev.hash||p.current.index!=r.prev.index))return void e.logger.warning("PropExchange.conflict",r.pid,", height: ",l?l.height:0,"mode: ",e.mode,"sim: ",o,t,"ori: ",p.current.hash,p.current.index);p=new n({pid:r.pid,cid:r.cid,oid:r.oid,gold:i.value,current:{hash:o,index:t,address:i.getAddress().toString()},height:0<e.curHeight?e.curHeight+1:0,pst:u.Ready,wid:0,account:""}),await e.propList.setVp(p,h),p={pid:p.pid,address:p.current.address,wid:p.wid,account:p.account,time:l.time,height:p.height,cid:p.cid},e.emit("prop/receive",p),s("prop/receive",p)}else{if(!(p=await e.propList.getVp(r.pid))||p.current.hash!=r.prev.hash||p.current.index!=r.prev.index)return void e.logger.warning("PropExchange.conflict",r.pid,", height: ",l?l.height:0,"mode: ",e.mode,"sim: ",o,t,"ori: ",p.current.hash,p.current.index);var d,f=p.current.address,m=i.getAddress().toString();if(p.current={hash:o,index:t,address:m},p.height=0<e.curHeight?e.curHeight+1:0,p.pst=u.Ready,await e.propList.setVp(p,h),e.mode==c.Block){if(p.cid==e.network.genesisId){for(d of(await e.propList.getVpByAddress(f)).list){if(d.cid==e.network.genesisId)break;e.voteMgr.delTokenAddress(f)}e.voteMgr.addTokenAddress(m)}m={pid:p.pid,oid:p.oid,cid:p.cid,src:f,dst:m,time:l.time,height:p.height},e.node.transmit("prop.exchange",m)}}let g=0,v=r;for(;i&&i.getReturnType(a.OP_PROPEXCHANGE)&&g++<2e3;){var y=v.prev,b=(e.middleHashChain.add(y.hash+y.index.toString()),await e.finder(y.hash));if(!b)break;if(i=b.outputs[y.index],!(v=i.getReturnData())||!v.prev||e.middleHashChain.has(v.prev.hash+v.prev.index.toString()))break}}async unconfirm(){var{env:e,data:t}=this.options,i=await e.finder(t.prev.hash);if(i&&i.outputs[t.prev.index]&&(n=i.outputs[t.prev.index]).getReturnData([a.OP_PROPEXCHANGE,a.OP_PROPCREATE])){var r=await e.propList.getVp(t.pid);if(r){var s,n=n.getAddress().toString(),o=r.current.address;if(r.current.hash=t.prev.hash,r.current.index=t.prev.index,r.current.address=n,await e.propList.setVp(r,i),e.mode==c.Block&&r.cid==e.network.genesisId){for(s of(await e.propList.getVpByAddress(o)).list){if(s.cid==e.network.genesisId)break;e.voteMgr.delTokenAddress(o)}e.voteMgr.addTokenAddress(n)}}}}async verify(){var{env:e,tx:t,i:i,data:a}=this.options;return r.strictEqual(a.prev.hash,t.inputs[i].prevout.hash),r.strictEqual(a.prev.index,t.inputs[i].prevout.index),await e.propList.getVp(a.pid),!0}}},function(e,t,i){var r=i(14);const a=i(5).ContractEnvType,s=i(32).VerifyError;var{}=i(19);const n=i(193);e.exports=class extends r{async insert(){var e=this.options.env,t=this.options.tx,i=t.hash("hex"),r=this.data;r.current={hash:i,index:0,address:t.outputs[0].getAddress().toString()},r.height=-1,await e.cpMemList.addItem(r)}async erase(){var e=this.options.env,t=this.data;await e.cpMemList.delItem(t)}async confirm(){var e=this.options.env,t=this.options.tx,i=t.hash("hex"),r=this.data;r.current={hash:i,index:0,address:t.outputs[0].getAddress().toString()},r.height=this.options.coinbaseHeight,r.status=1,await e.cpList.addItem(r),e.mode==a.Block&&(i={cid:r.cid,name:r.name,address:r.current.address},e.node.transmit("cp.create",i)),this.mode==a.Block&&await e.chain.node.mempool.cpMemList.delItem(r)}async unconfirm(){var e=this.options.env,t=this.data;this.options.tx,await e.cpList.delItem(t)}async verify(){var e=this.options.env,t=this.options.tx;if(!this.data)throw new s(t,"invalid","null cpRegister data",100);var i=n.verifyDataFormat(this.data);if(i)throw new s(t,"invalid",i,100);if((this.mode!=a.Block||"spv"!=e.node.nodeType)&&(i=this.mode!=a.Mempool,!await e.rpcExecute({method:"canExecute",params:[{confirm:i,cid:this.data.cid,name:this.data.name,oper:this.data.oper}]})))throw new s(t,"invalid info on "+this.data.oper,"cp.create",0);return!0}}},function(e,t,i){"use strict";
|
|
428
428
|
/*!
|
|
429
429
|
* cpHelper.js
|
|
430
430
|
* Copyright (c) 2019-2022, Bookman Software (MIT License).
|
package/lib/gamegold.js
CHANGED
|
@@ -206,7 +206,7 @@ var r=i(126),s=r.Buffer;function n(e,t){for(var i in e)t[i]=e[i]}function a(e,t,
|
|
|
206
206
|
* pkg.js - package constants
|
|
207
207
|
* Copyright (c) 2019-2022, Bookman Software (MIT License).
|
|
208
208
|
* https://github.com/bookmansoft/gamegold
|
|
209
|
-
*/t.protocol="vallnet",t.version="v5.4.
|
|
209
|
+
*/t.protocol="vallnet",t.version="v5.4.1",t.url="https://github.com/bookmansoft/gamegold"},function(e,t,i){"use strict";
|
|
210
210
|
/*!
|
|
211
211
|
* common.js - p2p constants for vallnet
|
|
212
212
|
* Copyright (c) 2019-2022, Bookman Software (MIT License).
|
|
@@ -438,7 +438,7 @@ function r(e){let t=null;var i=r.list[e.contract.options.type];return i?new(t=i.
|
|
|
438
438
|
*
|
|
439
439
|
* @note 为了让打包程序正常工作,没有使用自动化方案来引入类文件
|
|
440
440
|
*/
|
|
441
|
-
const r=i(5).ContractType;e.exports=function(e){if(!e)return i(188);switch(e.oper){case r.cpRegister:return i(192);case r.cpChange:return i(194);case r.coinbase:return i(195);case r.contractPromise:return i(196);case r.scRegister:return i(581);case r.scUpdate:return i(199);case r.scState:return i(200);case r.scRun:return i(201);case r.scNotify:return i(207);case r.propFound:return i(208);case r.vote:return i(209);case r.propSale:return i(210);case r.notify:return i(211);case r.contractCreate:return i(212);case r.contractExecute:return i(213);case r.erIssue:return i(214);case r.erAbolish:return i(215);case r.enchanceCp:return i(216);default:try{return i(582)("./"+e.oper)}catch(e){return i(14)}}}},function(e,t,i){var r=i(14);const s=i(19).nestingExtentCodes,n=i(117);e.exports=class extends r{async insert(){var e=this.getOpt();for(let i=0;i<e.tx.outputs.length;i++){var t=""+e.hash+i;e.env.middleHashMem.has(t)||this.setOptIndex(e,i)&&(await n(e).insert(),e.env.middleHashMem.add(t))}}async erase(){var e=this.getOpt();for(let t=0;t<e.tx.outputs.length;t++)e.env.middleHashMem.delete(""+e.hash+t),this.setOptIndex(e,t)&&await n(e).erase()}async confirm(){var e=this.getOpt();for(let i=0;i<e.tx.outputs.length;i++){var t=""+e.hash+i;e.env.middleHashChain.has(t)||this.setOptIndex(e,i)&&(await n(e).confirm(),e.env.middleHashChain.add(t))}}async unconfirm(){var e=this.getOpt();for(let t=0;t<e.tx.outputs.length;t++)e.env.middleHashChain.delete(""+e.hash+t),this.setOptIndex(e,t)&&await n(e).unconfirm()}async verify(){var e=this.getOpt();for(let i=0;i<e.tx.outputs.length;i++)if(this.setOptIndex(e,i)){var t=await n(e).verify();if(1!=t)return t}return!0}getOpt(){return{env:this.options.env,tx:this.options.tx,block:this.options.block,height:this.options.coinbaseHeight,hash:this.options.hash}}setOptIndex(e,t){return e.i=t,e.output=e.tx.outputs[t],e.type=e.output.getReturnType(),e.data=e.output.getReturnData(s),!!e.data}}},function(e,t,i){const{ContractEnvType:r,PropStatus:s}=i(5);var n=i(52);const a=i(7),o=i(148);e.exports=class extends n{async confirm(){var{env:e,i:t,output:i,data:n,hash:a,block:o,tx:c}=this.options,h=await e.propList.getVp(n.pid);!h||h.current.hash==a&&h.current.index==t?(n.current={hash:a,index:t,address:i.getAddress().toString()},n.height=0<e.curHeight?e.curHeight+1:0,n.pst=s.Ready,n.gold=i.value,await e.propList.setVp(n,c),e.mode==r.Block&&(i={pid:n.pid,oid:n.oid,cid:n.cid,dst:n.current.address,time:o.time,height:n.height,value:n.gold},e.node.transmit("prop.create",i))):e.logger.warning("PropCreate.conflict",n.pid,", height: ",o?o.height:0,"mode: ",e.mode,a,t,h.current.hash,h.current.index)}async unconfirm(){var e,{env:t,i:i,data:e,hash:r}=this.options;(e=await t.propList.getVp(e.pid))&&e.current.hash==r&&e.current.index==i&&await t.propList.delVp(e)}async verify(){var{env:e,output:t,data:i}=this.options;if(!o.unittest){var r=e.cpList.getItem(i.cid);if(!r||r.current.address!=t.getAddress().toString())return"PropCreate.errorAddress"}return t.value<a.MINPROPVALUE?"PropCreate.MINPROPVALUE":!e.network.tokenReg.test(i.pid)||"PropCreate.invalidPid"}}},function(e,t,i){const r=i(5).ContractEnvType;i=i(52);e.exports=class extends i{async confirm(){var{env:e,
|
|
441
|
+
const r=i(5).ContractType;e.exports=function(e){if(!e)return i(188);switch(e.oper){case r.cpRegister:return i(192);case r.cpChange:return i(194);case r.coinbase:return i(195);case r.contractPromise:return i(196);case r.scRegister:return i(581);case r.scUpdate:return i(199);case r.scState:return i(200);case r.scRun:return i(201);case r.scNotify:return i(207);case r.propFound:return i(208);case r.vote:return i(209);case r.propSale:return i(210);case r.notify:return i(211);case r.contractCreate:return i(212);case r.contractExecute:return i(213);case r.erIssue:return i(214);case r.erAbolish:return i(215);case r.enchanceCp:return i(216);default:try{return i(582)("./"+e.oper)}catch(e){return i(14)}}}},function(e,t,i){var r=i(14);const s=i(19).nestingExtentCodes,n=i(117);e.exports=class extends r{async insert(){var e=this.getOpt();for(let i=0;i<e.tx.outputs.length;i++){var t=""+e.hash+i;e.env.middleHashMem.has(t)||this.setOptIndex(e,i)&&(await n(e).insert(),e.env.middleHashMem.add(t))}}async erase(){var e=this.getOpt();for(let t=0;t<e.tx.outputs.length;t++)e.env.middleHashMem.delete(""+e.hash+t),this.setOptIndex(e,t)&&await n(e).erase()}async confirm(){var e=this.getOpt();for(let i=0;i<e.tx.outputs.length;i++){var t=""+e.hash+i;e.env.middleHashChain.has(t)||this.setOptIndex(e,i)&&(await n(e).confirm(),e.env.middleHashChain.add(t))}}async unconfirm(){var e=this.getOpt();for(let t=0;t<e.tx.outputs.length;t++)e.env.middleHashChain.delete(""+e.hash+t),this.setOptIndex(e,t)&&await n(e).unconfirm()}async verify(){var e=this.getOpt();for(let i=0;i<e.tx.outputs.length;i++)if(this.setOptIndex(e,i)){var t=await n(e).verify();if(1!=t)return t}return!0}getOpt(){return{env:this.options.env,tx:this.options.tx,block:this.options.block,height:this.options.coinbaseHeight,hash:this.options.hash}}setOptIndex(e,t){return e.i=t,e.output=e.tx.outputs[t],e.type=e.output.getReturnType(),e.data=e.output.getReturnData(s),!!e.data}}},function(e,t,i){const{ContractEnvType:r,PropStatus:s}=i(5);var n=i(52);const a=i(7),o=i(148);e.exports=class extends n{async confirm(){var{env:e,i:t,output:i,data:n,hash:a,block:o,tx:c}=this.options,h=await e.propList.getVp(n.pid);!h||h.current.hash==a&&h.current.index==t?(n.current={hash:a,index:t,address:i.getAddress().toString()},n.height=0<e.curHeight?e.curHeight+1:0,n.pst=s.Ready,n.gold=i.value,await e.propList.setVp(n,c),e.mode==r.Block&&(i={pid:n.pid,oid:n.oid,cid:n.cid,dst:n.current.address,time:o.time,height:n.height,value:n.gold},e.node.transmit("prop.create",i))):e.logger.warning("PropCreate.conflict",n.pid,", height: ",o?o.height:0,"mode: ",e.mode,a,t,h.current.hash,h.current.index)}async unconfirm(){var e,{env:t,i:i,data:e,hash:r}=this.options;(e=await t.propList.getVp(e.pid))&&e.current.hash==r&&e.current.index==i&&await t.propList.delVp(e)}async verify(){var{env:e,output:t,data:i}=this.options;if(!o.unittest){var r=e.cpList.getItem(i.cid);if(!r||r.current.address!=t.getAddress().toString())return"PropCreate.errorAddress"}return t.value<a.MINPROPVALUE?"PropCreate.MINPROPVALUE":!e.network.tokenReg.test(i.pid)||"PropCreate.invalidPid"}}},function(e,t,i){const r=i(5).ContractEnvType;i=i(52);e.exports=class extends i{async confirm(){var{env:e,i:t,output:i,data:s,hash:n,block:a}=this.options;e.mode==r.Block&&(s={data:s,height:0<e.curHeight?e.curHeight+1:0,gold:i.value,time:a.time,current:{hash:n,index:t,address:i.getAddress().toString()}},e.node.transmit("attach.confirm",s))}async unconfirm(){var{env:e,i:t,output:i,data:s,hash:n,block:a}=this.options;e.mode==r.Block&&(s={data:s,height:0<e.curHeight?e.curHeight+1:0,gold:i.value,time:a.time,current:{hash:n,index:t,address:i.getAddress().toString()}},e.node.transmit("attach.unconfirm",s))}async verify(){return!0}}},function(e,t,i){const r=i(0),s=i(19).opcodes,n=i(38).broadcast,a=i(132).vpItem;var o=i(52);const{ContractEnvType:c,PropStatus:h}=i(5);e.exports=class extends o{async confirm(){let{env:e,i:t,output:i,data:r,hash:o,tx:u,block:l}=this.options;if(e.mode==c.Wallet){var p=await e.propList.getVp(r.pid);if(p&&(p.current.hash!=r.prev.hash||p.current.index!=r.prev.index))return void e.logger.warning("PropExchange.conflict",r.pid,", height: ",l?l.height:0,"mode: ",e.mode,"sim: ",o,t,"ori: ",p.current.hash,p.current.index);p=new a({pid:r.pid,cid:r.cid,oid:r.oid,gold:i.value,current:{hash:o,index:t,address:i.getAddress().toString()},height:0<e.curHeight?e.curHeight+1:0,pst:h.Ready,wid:0,account:""}),await e.propList.setVp(p,u),p={pid:p.pid,address:p.current.address,wid:p.wid,account:p.account,time:l.time,height:p.height,cid:p.cid},e.emit("prop/receive",p),n("prop/receive",p)}else{if(!(p=await e.propList.getVp(r.pid))||p.current.hash!=r.prev.hash||p.current.index!=r.prev.index)return void e.logger.warning("PropExchange.conflict",r.pid,", height: ",l?l.height:0,"mode: ",e.mode,"sim: ",o,t,"ori: ",p.current.hash,p.current.index);var d,f=p.current.address,m=i.getAddress().toString();if(p.current={hash:o,index:t,address:m},p.height=0<e.curHeight?e.curHeight+1:0,p.pst=h.Ready,await e.propList.setVp(p,u),e.mode==c.Block){if(p.cid==e.network.genesisId){for(d of(await e.propList.getVpByAddress(f)).list){if(d.cid==e.network.genesisId)break;e.voteMgr.delTokenAddress(f)}e.voteMgr.addTokenAddress(m)}m={pid:p.pid,oid:p.oid,cid:p.cid,src:f,dst:m,time:l.time,height:p.height},e.node.transmit("prop.exchange",m)}}let g=0,y=r;for(;i&&i.getReturnType(s.OP_PROPEXCHANGE)&&g++<2e3;){var v=y.prev,b=(e.middleHashChain.add(v.hash+v.index.toString()),await e.finder(v.hash));if(!b)break;if(i=b.outputs[v.index],!(y=i.getReturnData())||!y.prev||e.middleHashChain.has(y.prev.hash+y.prev.index.toString()))break}}async unconfirm(){var{env:e,data:t}=this.options,i=await e.finder(t.prev.hash);if(i&&i.outputs[t.prev.index]&&(a=i.outputs[t.prev.index]).getReturnData([s.OP_PROPEXCHANGE,s.OP_PROPCREATE])){var r=await e.propList.getVp(t.pid);if(r){var n,a=a.getAddress().toString(),o=r.current.address;if(r.current.hash=t.prev.hash,r.current.index=t.prev.index,r.current.address=a,await e.propList.setVp(r,i),e.mode==c.Block&&r.cid==e.network.genesisId){for(n of(await e.propList.getVpByAddress(o)).list){if(n.cid==e.network.genesisId)break;e.voteMgr.delTokenAddress(o)}e.voteMgr.addTokenAddress(a)}}}}async verify(){var{env:e,tx:t,i:i,data:s}=this.options;return r.strictEqual(s.prev.hash,t.inputs[i].prevout.hash),r.strictEqual(s.prev.index,t.inputs[i].prevout.index),await e.propList.getVp(s.pid),!0}}},function(e,t,i){var r=i(14);const s=i(5).ContractEnvType,n=i(32).VerifyError;var{}=i(19);const a=i(193);e.exports=class extends r{async insert(){var e=this.options.env,t=this.options.tx,i=t.hash("hex"),r=this.data;r.current={hash:i,index:0,address:t.outputs[0].getAddress().toString()},r.height=-1,await e.cpMemList.addItem(r)}async erase(){var e=this.options.env,t=this.data;await e.cpMemList.delItem(t)}async confirm(){var e=this.options.env,t=this.options.tx,i=t.hash("hex"),r=this.data;r.current={hash:i,index:0,address:t.outputs[0].getAddress().toString()},r.height=this.options.coinbaseHeight,r.status=1,await e.cpList.addItem(r),e.mode==s.Block&&(i={cid:r.cid,name:r.name,address:r.current.address},e.node.transmit("cp.create",i)),this.mode==s.Block&&await e.chain.node.mempool.cpMemList.delItem(r)}async unconfirm(){var e=this.options.env,t=this.data;this.options.tx,await e.cpList.delItem(t)}async verify(){var e=this.options.env,t=this.options.tx;if(!this.data)throw new n(t,"invalid","null cpRegister data",100);var i=a.verifyDataFormat(this.data);if(i)throw new n(t,"invalid",i,100);if((this.mode!=s.Block||"spv"!=e.node.nodeType)&&(i=this.mode!=s.Mempool,!await e.rpcExecute({method:"canExecute",params:[{confirm:i,cid:this.data.cid,name:this.data.name,oper:this.data.oper}]})))throw new n(t,"invalid info on "+this.data.oper,"cp.create",0);return!0}}},function(e,t,i){"use strict";
|
|
442
442
|
/*!
|
|
443
443
|
* cpHelper.js
|
|
444
444
|
* Copyright (c) 2019-2022, Bookman Software (MIT License).
|