tx · 7FRUR3gvWP5rWPzWhGqcJ9r52QZoZVCQP4xAuwbZ7Src 3MtkCfhJSAZ6P2bsBM2DdpurZ7S1vepUvrc: -0.01400000 Waves 2019.09.28 13:02 [696141] smart account 3MtkCfhJSAZ6P2bsBM2DdpurZ7S1vepUvrc > SELF 0.00000000 Waves
{ "type": 13, "id": "7FRUR3gvWP5rWPzWhGqcJ9r52QZoZVCQP4xAuwbZ7Src", "fee": 1400000, "feeAssetId": null, "timestamp": 1569664950497, "version": 1, "sender": "3MtkCfhJSAZ6P2bsBM2DdpurZ7S1vepUvrc", "senderPublicKey": "5M8TjFdQ2hPL23uw5RrCvaES2qU4NpCtn68zqTyiYm2E", "proofs": [ "Cs35oyCAWXLL9pKLn1GpNhTQYKNRaHSVEoy6oG6DpkVgBchMp58xu8PLGZsfYtE51k9csfusZkoKeVV6JTdvhnq" ], "script": "base64:AAIDAAAAAAAAAAAAAAAGAAAAAAdXQVZFTEVUCQAAaAAAAAIJAABoAAAAAgAAAAAAAAAAZAAAAAAAAAAD6AAAAAAAAAAD6AAAAAAKQ09NTUlTU0lPTgkAAGkAAAACCQAAaAAAAAIAAAAAAAAAAAUFAAAAB1dBVkVMRVQAAAAAAAAAA+gAAAAAB3Rva2VuSUQJAAJZAAAAAQIAAAAsNHlzWmVVdnRCclNWZ0o5djNNZmgzYldEMldOUGQ1a1E4MjdwaW9nd3BNeDQAAAAACXByaXplUG9vbAkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABAgAAACMzTXJxelhmUVdUcmhySjZHQmFtU3dLS0R6MzFnZFhMZ0NhcgAAAAAHcHJvamVjdAkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABAgAAACMzTjVMeTRia3ZnNXVGamY5QnBlQXNpazhMcTJzZkhZYzJIVQAAAAANcGxheWVyU3RvcmFnZQkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABAgAAACMzTXhaYVdKb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AQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAlwcml6ZVBvb2wFAAAADGhhbGZPZkRvbmF0ZQUAAAAEdW5pdAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAdwcm9qZWN0BQAAAAxoYWxmT2ZEb25hdGUFAAAABHVuaXQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAARZ2FtZVdhbGxldEFkZHJlc3MFAAAADHRva2Vuc0Ftb3VudAUAAAAHdG9rZW5JRAUAAAADbmlsAAAAAAGAkLA=", "chainId": 84, "height": 696141, "spentComplexity": 0 } View: original | compacted Prev: 88BegFtmyQekX8UQsjDD3rVCDhH2yA8818e2GnEwPkA8 Next: 4vugug8ibZFiNugdZ9yV6NJuN5Vqepbcf5jTDQgfroZv Diff:
Old | New | Differences | |
---|---|---|---|
18 | 18 | let txId = toBase58String(i.transactionId) | |
19 | 19 | let pmt = extract(i.payment) | |
20 | 20 | let paymentAmt = pmt.amount | |
21 | - | let halfOfDonate = ((paymentAmt - COMMISSION) / 2) | |
22 | - | let paymentSum = ((paymentAmt - COMMISSION) / WAVELET) | |
23 | - | let isExistPackage = isDefined(getStringValue(this, packageName)) | |
24 | - | if (!(isExistPackage)) | |
25 | - | then throw("This package doesn't exist anymore") | |
21 | + | if ((1 == 1)) | |
22 | + | then throw(toString(paymentAmt)) | |
26 | 23 | else { | |
27 | - | let | |
28 | - | let | |
29 | - | let | |
30 | - | if (( | |
31 | - | then throw( | |
24 | + | let halfOfDonate = ((paymentAmt - COMMISSION) / 2) | |
25 | + | let paymentSum = ((paymentAmt - COMMISSION) / WAVELET) | |
26 | + | let isExistPackage = isDefined(getStringValue(this, packageName)) | |
27 | + | if (!(isExistPackage)) | |
28 | + | then throw("This package doesn't exist anymore") | |
32 | 29 | else { | |
33 | - | let betNotInWaves = isDefined(pmt.assetId) | |
34 | - | let feeNotInWaves = isDefined(pmt.assetId) | |
35 | - | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
36 | - | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
37 | - | if (betNotInWaves) | |
38 | - | then throw("Bet amount must be in Waves") | |
39 | - | else if (feeNotInWaves) | |
40 | - | then throw("Transaction's fee must be in Waves") | |
41 | - | else { | |
42 | - | let playerAddressStr = toString(playerAddress) | |
43 | - | let paymentSumStr = toString(paymentSum) | |
44 | - | let gameWalletStr = getStringValue(playerStorage, (playerID + "_address")) | |
45 | - | let gameWalletAddress = addressFromStringValue(gameWalletStr) | |
46 | - | TransferSet([ScriptTransfer(prizePool, halfOfDonate, unit), ScriptTransfer(project, halfOfDonate, unit), ScriptTransfer(gameWalletAddress, tokensAmount, tokenID)]) | |
47 | - | } | |
30 | + | let packageNameData = split(packageName, "_") | |
31 | + | let tokensAmount = parseIntValue(packageNameData[0]) | |
32 | + | let actualPrice = parseIntValue(getStringValue(this, packageName)) | |
33 | + | if ((paymentSum != actualPrice)) | |
34 | + | then throw(((("Donation amount should be " + toString(actualPrice)) + " Waves, but we got ") + toString(paymentSum))) | |
35 | + | else { | |
36 | + | let betNotInWaves = isDefined(pmt.assetId) | |
37 | + | let feeNotInWaves = isDefined(pmt.assetId) | |
38 | + | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
39 | + | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
40 | + | if (betNotInWaves) | |
41 | + | then throw("Bet amount must be in Waves") | |
42 | + | else if (feeNotInWaves) | |
43 | + | then throw("Transaction's fee must be in Waves") | |
44 | + | else { | |
45 | + | let playerAddressStr = toString(playerAddress) | |
46 | + | let paymentSumStr = toString(paymentSum) | |
47 | + | let gameWalletStr = getStringValue(playerStorage, (playerID + "_address")) | |
48 | + | let gameWalletAddress = addressFromStringValue(gameWalletStr) | |
49 | + | TransferSet([ScriptTransfer(prizePool, halfOfDonate, unit), ScriptTransfer(project, halfOfDonate, unit), ScriptTransfer(gameWalletAddress, tokensAmount, tokenID)]) | |
50 | + | } | |
51 | + | } | |
48 | 52 | } | |
49 | 53 | } | |
50 | 54 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let WAVELET = ((100 * 1000) * 1000) | |
5 | 5 | ||
6 | 6 | let COMMISSION = ((5 * WAVELET) / 1000) | |
7 | 7 | ||
8 | 8 | let tokenID = fromBase58String("4ysZeUvtBrSVgJ9v3Mfh3bWD2WNPd5kQ827piogwpMx4") | |
9 | 9 | ||
10 | 10 | let prizePool = addressFromStringValue("3MrqzXfQWTrhrJ6GBamSwKKDz31gdXLgCar") | |
11 | 11 | ||
12 | 12 | let project = addressFromStringValue("3N5Ly4bkvg5uFjf9BpeAsik8Lq2sfHYc2HU") | |
13 | 13 | ||
14 | 14 | let playerStorage = addressFromStringValue("3MxZaWJmdypjv8MMv8RPTtDq4GNMPdCisJP") | |
15 | 15 | ||
16 | 16 | @Callable(i) | |
17 | 17 | func buy (playerID,packageName) = { | |
18 | 18 | let txId = toBase58String(i.transactionId) | |
19 | 19 | let pmt = extract(i.payment) | |
20 | 20 | let paymentAmt = pmt.amount | |
21 | - | let halfOfDonate = ((paymentAmt - COMMISSION) / 2) | |
22 | - | let paymentSum = ((paymentAmt - COMMISSION) / WAVELET) | |
23 | - | let isExistPackage = isDefined(getStringValue(this, packageName)) | |
24 | - | if (!(isExistPackage)) | |
25 | - | then throw("This package doesn't exist anymore") | |
21 | + | if ((1 == 1)) | |
22 | + | then throw(toString(paymentAmt)) | |
26 | 23 | else { | |
27 | - | let | |
28 | - | let | |
29 | - | let | |
30 | - | if (( | |
31 | - | then throw( | |
24 | + | let halfOfDonate = ((paymentAmt - COMMISSION) / 2) | |
25 | + | let paymentSum = ((paymentAmt - COMMISSION) / WAVELET) | |
26 | + | let isExistPackage = isDefined(getStringValue(this, packageName)) | |
27 | + | if (!(isExistPackage)) | |
28 | + | then throw("This package doesn't exist anymore") | |
32 | 29 | else { | |
33 | - | let betNotInWaves = isDefined(pmt.assetId) | |
34 | - | let feeNotInWaves = isDefined(pmt.assetId) | |
35 | - | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
36 | - | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
37 | - | if (betNotInWaves) | |
38 | - | then throw("Bet amount must be in Waves") | |
39 | - | else if (feeNotInWaves) | |
40 | - | then throw("Transaction's fee must be in Waves") | |
41 | - | else { | |
42 | - | let playerAddressStr = toString(playerAddress) | |
43 | - | let paymentSumStr = toString(paymentSum) | |
44 | - | let gameWalletStr = getStringValue(playerStorage, (playerID + "_address")) | |
45 | - | let gameWalletAddress = addressFromStringValue(gameWalletStr) | |
46 | - | TransferSet([ScriptTransfer(prizePool, halfOfDonate, unit), ScriptTransfer(project, halfOfDonate, unit), ScriptTransfer(gameWalletAddress, tokensAmount, tokenID)]) | |
47 | - | } | |
30 | + | let packageNameData = split(packageName, "_") | |
31 | + | let tokensAmount = parseIntValue(packageNameData[0]) | |
32 | + | let actualPrice = parseIntValue(getStringValue(this, packageName)) | |
33 | + | if ((paymentSum != actualPrice)) | |
34 | + | then throw(((("Donation amount should be " + toString(actualPrice)) + " Waves, but we got ") + toString(paymentSum))) | |
35 | + | else { | |
36 | + | let betNotInWaves = isDefined(pmt.assetId) | |
37 | + | let feeNotInWaves = isDefined(pmt.assetId) | |
38 | + | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
39 | + | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
40 | + | if (betNotInWaves) | |
41 | + | then throw("Bet amount must be in Waves") | |
42 | + | else if (feeNotInWaves) | |
43 | + | then throw("Transaction's fee must be in Waves") | |
44 | + | else { | |
45 | + | let playerAddressStr = toString(playerAddress) | |
46 | + | let paymentSumStr = toString(paymentSum) | |
47 | + | let gameWalletStr = getStringValue(playerStorage, (playerID + "_address")) | |
48 | + | let gameWalletAddress = addressFromStringValue(gameWalletStr) | |
49 | + | TransferSet([ScriptTransfer(prizePool, halfOfDonate, unit), ScriptTransfer(project, halfOfDonate, unit), ScriptTransfer(gameWalletAddress, tokensAmount, tokenID)]) | |
50 | + | } | |
51 | + | } | |
48 | 52 | } | |
49 | 53 | } | |
50 | 54 | } | |
51 | 55 | ||
52 | 56 |
github/deemru/w8io/026f985 28.97 ms ◑