tx · A23sR2sNWSQDrFEB3io77bLk2Tp2sMkJp3119GQDj5go

3NC7GJvfMCykyTMSe9KU2rJmVygk1fzzKpC:  -0.01400000 Waves

2020.04.10 13:05 [948102] smart account 3NC7GJvfMCykyTMSe9KU2rJmVygk1fzzKpC > SELF 0.00000000 Waves

{ "type": 13, "id": "A23sR2sNWSQDrFEB3io77bLk2Tp2sMkJp3119GQDj5go", "fee": 1400000, "feeAssetId": null, "timestamp": 1586513145060, "version": 1, "sender": "3NC7GJvfMCykyTMSe9KU2rJmVygk1fzzKpC", "senderPublicKey": "BNrrKkZSXXCbcCtXLT3VMQnSAJt2jt8TLnZWaB5US3Ci", "proofs": [ "2qGsECRsaVLHYBC8Tvj8iXBDgSYKbopPEPvS8xsQxTpBR4Vsfmb6i94dFKB4H7LBxAF57sQVjCLyVkbaxntTLrLX" ], "script": "base64:AAIDAAAAAAAAAAoIARIAEgQKAgEIAAAABAAAAAAEdXNkbgEAAAAgImQ/Hr5gRukRahMT3KYz/hZ+B/l36bPyFfyZSSowCjcBAAAACmdldEJhbGFuY2UAAAACAAAAB2FkZHJlc3MAAAAHYXNzZXRJZAQAAAABYgkABBoAAAACBQAAAAR0aGlzCQABLAAAAAIJAAEsAAAAAgUAAAAHYWRkcmVzcwIAAAABXwUAAAAHYXNzZXRJZAQAAAAHJG1hdGNoMAUAAAABYgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAF0BQAAAAckbWF0Y2gwBQAAAAF0AAAAAAAAAAAAAQAAAApnZXRBc3NldElkAAAAAQAAAAdhc3NldElkBAAAAAckbWF0Y2gwBQAAAAdhc3NldElkAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAApCeXRlVmVjdG9yBAAAAAFiBQAAAAckbWF0Y2gwCQACWAAAAAEFAAAAAWICAAAABVdBVkVTAQAAAA5hc3NldElkVG9CeXRlcwAAAAEAAAAHYXNzZXRJZAMJAAAAAAAAAgUAAAAHYXNzZXRJZAIAAAAFV0FWRVM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mFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAGYW1vdW50CQEAAAAOYXNzZXRJZFRvQnl0ZXMAAAABBQAAAAdhc3NldElkBQAAAANuaWwJAAACAAAAAQkAASwAAAACAgAAABBZb3VyIGJhbGFuY2UgaXMgCQABpAAAAAEFAAAAA2JhbAAAAACIdwrz", "chainId": 84, "height": 948102, "spentComplexity": 0 } View: original | compacted Prev: 8SALX1ha7bkpGdEABvRuym5YaAmEnCKypqCV94DEYzer Next: D1pfZeBq4bqTMMABvr8SAsC3RfyNwiakJC9Je2fHgeDf Diff:
OldNewDifferences
33 {-# CONTENT_TYPE DAPP #-}
44 let usdn = base58'3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC'
55
6-func getBalance (address) = {
7- let b = getInteger(this, address)
6+func getBalance (address,assetId) = {
7+ let b = getInteger(this, ((address + "_") + assetId))
88 match b {
99 case t: Int =>
1010 t
1414 }
1515
1616
17+func getAssetId (assetId) = match assetId {
18+ case b: ByteVector =>
19+ toBase58String(b)
20+ case _ =>
21+ "WAVES"
22+}
23+
24+
25+func assetIdToBytes (assetId) = if ((assetId == "WAVES"))
26+ then unit
27+ else fromBase58String(assetId)
28+
29+
1730 @Callable(i)
1831 func deposit () = {
1932 let address = toBase58String(i.caller.bytes)
20- let bal = getBalance(address)
2133 let payment = extract(i.payment)
22- if ((payment.assetId == usdn))
23- then ScriptResult(WriteSet([DataEntry(address, (bal + payment.amount))]), TransferSet(nil))
24- else throw("Should be USDN")
34+ let assetId = getAssetId(payment.assetId)
35+ let bal = getBalance(address, assetId)
36+ ScriptResult(WriteSet([DataEntry(((address + "_") + assetId), (bal + payment.amount))]), TransferSet(nil))
2537 }
2638
2739
2840
2941 @Callable(i)
30-func withdraw (amount) = {
42+func withdraw (amount,assetId) = {
3143 let address = toBase58String(i.caller.bytes)
32- let bal = getBalance(address)
44+ let bal = getBalance(address, assetId)
3345 if ((bal >= amount))
34- then ScriptResult(WriteSet([DataEntry(address, (bal - amount))]), TransferSet([ScriptTransfer(i.caller, amount, usdn)]))
46+ then ScriptResult(WriteSet([DataEntry(((address + "_") + assetId), (bal - amount))]), TransferSet([ScriptTransfer(i.caller, amount, assetIdToBytes(assetId))]))
3547 else throw(("Your balance is " + toString(bal)))
3648 }
3749
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let usdn = base58'3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC'
55
6-func getBalance (address) = {
7- let b = getInteger(this, address)
6+func getBalance (address,assetId) = {
7+ let b = getInteger(this, ((address + "_") + assetId))
88 match b {
99 case t: Int =>
1010 t
1111 case _ =>
1212 0
1313 }
1414 }
1515
1616
17+func getAssetId (assetId) = match assetId {
18+ case b: ByteVector =>
19+ toBase58String(b)
20+ case _ =>
21+ "WAVES"
22+}
23+
24+
25+func assetIdToBytes (assetId) = if ((assetId == "WAVES"))
26+ then unit
27+ else fromBase58String(assetId)
28+
29+
1730 @Callable(i)
1831 func deposit () = {
1932 let address = toBase58String(i.caller.bytes)
20- let bal = getBalance(address)
2133 let payment = extract(i.payment)
22- if ((payment.assetId == usdn))
23- then ScriptResult(WriteSet([DataEntry(address, (bal + payment.amount))]), TransferSet(nil))
24- else throw("Should be USDN")
34+ let assetId = getAssetId(payment.assetId)
35+ let bal = getBalance(address, assetId)
36+ ScriptResult(WriteSet([DataEntry(((address + "_") + assetId), (bal + payment.amount))]), TransferSet(nil))
2537 }
2638
2739
2840
2941 @Callable(i)
30-func withdraw (amount) = {
42+func withdraw (amount,assetId) = {
3143 let address = toBase58String(i.caller.bytes)
32- let bal = getBalance(address)
44+ let bal = getBalance(address, assetId)
3345 if ((bal >= amount))
34- then ScriptResult(WriteSet([DataEntry(address, (bal - amount))]), TransferSet([ScriptTransfer(i.caller, amount, usdn)]))
46+ then ScriptResult(WriteSet([DataEntry(((address + "_") + assetId), (bal - amount))]), TransferSet([ScriptTransfer(i.caller, amount, assetIdToBytes(assetId))]))
3547 else throw(("Your balance is " + toString(bal)))
3648 }
3749
3850

github/deemru/w8io/026f985 
22.15 ms