You are viewing a single comment's thread from:

RE: Test title

in #topic16 years ago

{
"id": "ssc-b8923f70-c1f7-497f-961i",
"json": {
"contractName": "contract",
"contractAction": "deploy",
"contractPayload": {
"name": "token",
"code": "YWN0aW9ucy5jcmVhdGVTU0MgPSBmdW5jdGlvbiAocGF5bG9hZCkgewogIGRiLmNyZWF0ZVRhYmxlKCd0b2tlbnMnKTsKICBkYi5jcmVhdGVUYWJsZSgnYmFsYW5jZXMnKTsKfQoKYWN0aW9ucy5jcmVhdGUgPSBmdW5jdGlvbiAocGF5bG9hZCkgewogIGNvbnN0IHsgc3ltYm9sLCBwcmVjaXNpb24sIG1heFN1cHBseSB9ID0gcGF5bG9hZDsKCiAgaWYgKHN5bWJvbCAmJiB0eXBlb2Ygc3ltYm9sID09PSAnc3RyaW5nJwogICAgJiYgKHByZWNpc2lvbiAmJiB0eXBlb2YgcHJlY2lzaW9uID09PSAnbnVtYmVyJyB8fCBwcmVjaXNpb24gPT09IDApCiAgICAmJiBtYXhTdXBwbHkgJiYgdHlwZW9mIG1heFN1cHBseSA9PT0gJ251bWJlcicpIHsKCiAgICBjb25zdCBSZWdleFB1cmVMZXR0ZXJzID0gL15bYS16QS1aXSskLzsKCiAgICAvLyB0aGUgc3ltYm9sIG11c3QgYmUgbWFkZSBvZiBsZXR0ZXJzIG9ubHkKICAgIC8vIHRoZSBwcmVjaXNpb24gbXVzdCBiZSBiZXR3ZWVuIDAgYW5kIDggYW5kIG11c3QgYmUgYW4gaW50ZWdlcgogICAgLy8gdGhlIG1heCBzdXBwbHkgbXVzdCBiZSBwb3NpdGl2ZQogICAgaWYgKGFzc2VydChSZWdleFB1cmVMZXR0ZXJzLnRlc3Qoc3ltYm9sKSwgJ2ludmFsaWQgc3ltYm9sJykKICAgICAgJiYgYXNzZXJ0KChwcmVjaXNpb24gPj0gMCAmJiBwcmVjaXNpb24gPD0gOCkgJiYgKE51bWJlci5pc0ludGVnZXIocHJlY2lzaW9uKSksICdpbnZhbGlkIHByZWNpc2l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QoKbGV0IGNhbGN1bGF0ZUJhbGFuY2UgPSBmdW5jdGlvbiAoYmFsYW5jZSwgcXVhbnRpdHksIHByZWNpc2lvbiwgYWRkKSB7CiAgaWYgKHByZWNpc2lvbiA9PT0gMCkgewogICAgcmV0dXJuIGFkZCA/IGJhbGFuY2UgKyBxdWFudGl0eSA6IGJhbGFuY2UgLSBxdWFudGl0eQogIH0KCiAgbGV0IHJhdGUgPSBNYXRoLnBvdygxMCwgcHJlY2lzaW9uKTsKICBsZXQgdG1wUXR5ID0gcXVhbnRpdHkgKiByYXRlOwogIGxldCB0bXBCYWxhbmNlID0gYmFsYW5jZSAqIHJhdGU7CgogIHJldHVybiBhZGQgPyAodG1wQmFsYW5jZSArIHRtcFF0eSkgLyByYXRlIDogKHRtcEJhbGFuY2UgLSB0bXBRdHkpIC8gcmF0ZTsKfQoKbGV0IGNvdW50RGVjaW1hbHMgPSBmdW5jdGlvbiAodmFsdWUpIHsKICBpZiAoTWF0aC5mbG9vcih2YWx1ZSkgPT09IHZhbHVlKSByZXR1cm4gMDsKICByZXR1cm4gdmFsdWUudG9TdHJpbmcoKS5zcGxpdCgnLicpWzFdLmxlbmd0aCB8fCAwOwp9"
}
}
}

Sort:  

{
"id": "ssc-b8923f70-c1f7-497f-961i",
"json": {
"contractName": "token",
"contractAction": "create",
"contractPayload": {
"symbol": "PKTC",
"precision": 0,
"maxSupply": 1000000
}
}
}

{
"id": "ssc-b8923f70-c1f7-497f-961i",
"json": {
"contractName": "token",
"contractAction": "issue",
"contractPayload": {
"symbol": "PKTC",
"to": "harpagon",
"quantity": 1000
}
}
}

{
"id": "ssc-b8923f70-c1f7-497f-961j",
"json": {
"contractName": "contract",
"contractAction": "deploy",
"contractPayload": {
"name": "account",
"code": "YWN0aW9ucy5jcmVhdGVTU0MgPSBmdW5jdGlvbiAocGF5bG9hZCkgewogIGRiLmNyZWF0ZVRhYmxlKCdhY2NvdW50cycpOwp9CgovLyByZWdpc3RlciBhbiBhY2NvdW50IGhlbHBzIG90aGVyIGNvbnRyYWN0cyB0byBrbm93IAovLyBpZiBhbiBhY2NvdW50IGV4aXN0cyBvbiB0aGUgU3RlZW0gYmxvY2tjaGFpbgphY3Rpb25zLnJlZ2lzdGVyID0gZnVuY3Rpb24gKHBheWxvYWQpIHsKICBsZXQgYWNjb3VudHMgPSBkYi5nZXRUYWJsZSgnYWNjb3VudHMnKTsKCiAgbGV0IGFjY291bnQgPSBhY2NvdW50cy5maW5kT25lKHsgJ2lkJzogc2VuZGVyIH0pOwoKICBpZiAoYWNjb3VudCA9PT0gbnVsbCkgewogICAgY29uc3QgbmV3QWNjb3VudCA9IHsKICAgICAgJ2lkJzogc2VuZGVyCiAgICB9OwoKICAgIGFjY291bnRzLmluc2VydChuZXdBY2NvdW50KTsKICB9IAp9"
}
}
}

{
"id": "ssc-b8923f70-c1f7-497f-961j",
"json": {
"contractName": "account",
"contractAction": "register",
"contractPayload": {}
}
}

{
"id": "ssc-b8923f70-c1f7-497f-961j",
"json": {
"contractName": "contract",
"contractAction": "deploy",
"contractPayload": {
"name": "token",
"code": "YWN0aW9ucy5jcmVhdGVTU0MgPSBmdW5jdGlvbiAocGF5bG9hZCkgewogIGRiLmNyZWF0ZVRhYmxlKCdhY2NvdW50cycpOwp9CgovLyByZWdpc3RlciBhbiBhY2NvdW50IGhlbHBzIG90aGVyIGNvbnRyYWN0cyB0byBrbm93IAovLyBpZiBhbiBhY2NvdW50IGV4aXN0cyBvbiB0aGUgU3RlZW0gYmxvY2tjaGFpbgphY3Rpb25zLnJlZ2lzdGVyID0gZnVuY3Rpb24gKHBheWxvYWQpIHsKICBsZXQgYWNjb3VudHMgPSBkYi5nZXRUYWJsZSgnYWNjb3VudHMnKTsKCiAgbGV0IGFjY291bnQgPSBhY2NvdW50cy5maW5kT25lKHsgJ2lkJzogc2VuZGVyIH0pOwoKICBpZiAoYWNjb3VudCA9PT0gbnVsbCkgewogICAgY29uc3QgbmV3QWNjb3VudCA9IHsKICAgICAgJ2lkJz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BiZWZvcmUKICAgICAgaWYgKGFzc2VydChhY2NvdW50ICE9PSBudWxsLCAndG8gYWNjb3VudCBkb2VzIG5vdCBleGlzdCcpKSB7CiAgICAgICAgbGV0IHRva2VucyA9IGRiLmdldFRhYmxlKCd0b2tlbnMnKTsKICAgICAgICBsZXQgdG9rZW4gPSB0b2tlbnMuZmluZE9uZSh7IHN5bWJvbCB9KTsKCiAgICAgICAgLy8gdGhlIHN5bWJvbCBtdXN0IGV4aXN0CiAgICAgICAgLy8gdGhlbiB3ZSBuZWVkIHRvIGNoZWNrIHRoYXQgdGhlIHF1YW50aXR5IGlzIGNvcnJlY3QKICAgICAgICBpZiAoYXNzZXJ0KHRva2VuICE9PSBudWxsLCAnc3ltYm9sIGRvZXMgbm90IGV4aXN0JykKICAgICAgICAgICYmIGFzc2VydChjb3VudERlY2ltYWxzKHF1YW50aXR5KSA8PSB0b2tlbi5wcmVjaXNpb24sICdzeW1ib2wgcHJlY2lzaW9uIG1pc21hdGNoJykKICAgICAgICAgICYmIGFzc2VydChxdWFudGl0eSA"
}
}
}

{
"id": "ssc-b8923f70-c1f7-497f-961j",
"json": {
"contractName": "token",
"contractAction": "create",
"contractPayload": {
"symbol": "PKTC",
"precision": 0,
"maxSupply": 1000000
}
}
}

{
"id": "ssc-b8923f70-c1f7-497f-961j",
"json": {
"contractName": "token",
"contractAction": "issue",
"contractPayload": {
"symbol": "PKTC",
"to": "harpagon",
"quantity": 1000
}
}
}