#0
nonstandard
0.00004000 BSV
Q!h²ÌÃîéàãÌ}©ÑE¹m^!߬ü[y¹V9!h²ÌÃîéàãÌ}©ÑE¹m^!߬ü[y¹V9!h²ÌÃîéàãÌ}©ÑE¹m^!߬ü[y¹V9S®MK{"__cls":"class SubTradeSC {\r\n constructor(\r\n owners = [],\r\n fundFromId,\r\n fundToId,\r\n batchOrderId,\r\n subBatchOrderId,\r\n positionId,\r\n positionSellingAmount,\r\n chatId,\r\n stateMachine = [\r\n ['Approve trade', ['buyer', 'seller', 'agent'], [false, false, false]],\r\n ['Approve A&A', ['buyer', 'seller', 'agent'], [false, false, false]],\r\n ['Approve LSTA', ['buyer', 'seller'], [false, false]],\r\n ['Transfer Position', ['seller'], [false]],\r\n ['Finalize Trade', ['agent'], [false]],\r\n ]\r\n ) {\r\n this._owners = owners;\r\n this.fundFromId = fundFromId;\r\n this.fundToId = fundToId;\r\n this.batchOrderId = batchOrderId;\r\n this.subBatchOrderId = subBatchOrderId;\r\n this.positionId = positionId;\r\n this.positionSellingPercentage = positionSellingAmount;\r\n this.chatId = chatId;\r\n this.stateMachine = stateMachine;\r\n this.finalized = false;\r\n this.stateMachineSteps = 0;\r\n // TODO: stateMachine check for correct format\r\n for (let i = 0; i < stateMachine.length; i += 1) {\r\n this.stateMachineSteps += stateMachine[i][1].length;\r\n }\r\n this.currentStateMachineStep = 0;\r\n }\r\n\r\n setPositionSellingAmount(newPositionSellingPercentage) {\r\n this.positionSellingPercentage = newPositionSellingPercentage;\r\n }\r\n\r\n // position to be sold\r\n setPosition(positionId) {\r\n this.positionId = positionId;\r\n }\r\n\r\n addOwner(pubKey) {\r\n this._owners.push(pubKey);\r\n }\r\n\r\n setChatId(chatId) {\r\n this.chatId = chatId;\r\n }\r\n\r\n updateStateMachine(stepName, role) {\r\n const findStep = state => {\r\n return state === stepName;\r\n };\r\n const stepIndex = this.stateMachine.findIndex(findStep);\r\n if (stepIndex < 0) throw new Error(`Step ${stepName} of State Machine doesnt exist.`);\r\n for (let i = 0; i <= stepIndex; i += 1) {\r\n for (let j = 0; j < this.stateMachine[i][2].length; j += 1) {\r\n if (!this.stateMachine[i][j]) throw new Error(`Step ${this.stateMachine[i]} of State Machine isn't finished.`);\r\n }\r\n }\r\n const findRole = stepRole => {\r\n return stepRole === role;\r\n };\r\n const stepRole = this.stateMachine.findIndex(findRole);\r\n if (stepRole < 0) throw new Error(`Step ${stepName} of State Machine doesnt have ${role} role.`);\r\n if (!this.stateMachine[stepIndex][stepRole]) {\r\n this.stateMachine[stepIndex][stepRole] = true;\r\n this.currentStateMachineStep += 1;\r\n }\r\n }\r\n}","__index":{"obj":0},"__func":"constructor","__args":[["0368b28a1bcc1112c3eee9e0e3cc7da99ed145b96d5e21dfacfc5b798fb9569739","0368b28a1bcc1112c3eee9e0e3cc7da99ed145b96d5e21dfacfc5b798fb9569739","0368b28a1bcc1112c3eee9e0e3cc7da99ed145b96d5e21dfacfc5b798fb9569739"],"2ef01502f391a67b90ae5ee12b1afbc78869dce0bba32fc6564665ff595c9fe7:0","47fc982aac4b6148aea7302b2c969b969a49c5ddccf7268324eaa733e447e2c6:0","tbd","b10ab95ad1096926f740c15ce0dbb2d4dade30027f9354b855dca500b2c605b5:0","8dbb7aa8b04d079e0c79c5fa67cd674161552f090a98b09f7fb8c055a084afae:1",1,"tbd"]}u
https://whatsonchain.com/tx/3ddb595aab10089e3212bf2fc18412785ea9dc2a210e331ef3e04654ff65bea3