-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathformat.test.js.snap
More file actions
135 lines (114 loc) · 4.45 KB
/
format.test.js.snap
File metadata and controls
135 lines (114 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`SplittableCommodity.sol format 1`] = `
====================================options=====================================
parsers: ["slang"]
printWidth: 80
| printWidth
=====================================input======================================
pragma solidity ^0.4.24;
import "./MintableCommodity.sol";
import "../participant/ISupplier.sol";
import "../../node_modules/zeppelin-solidity/contracts//math/SafeMath.sol";
contract SplittableCommodity is MintableCommodity {
using SafeMath for uint256;
event Split(address indexed to, uint256 amount, uint64 parentId, address indexed operator, bytes operatorData);
function split(uint _tokenId, address _to, uint256 _amount) public whenNotPaused {
address supplierProxy = IContractRegistry(contractRegistry).getLatestProxyAddr("Supplier");
require(
msg.sender == IContractRegistry(contractRegistry).getLatestProxyAddr("FifoCrcMarket") ||
ISupplier(supplierProxy).isAllowed(this, "IMintableCommodity"),
"Splitting can only be done when both the ISplittableCommodity interface is enabled and is called by a supplier or the FifoCrcMarket is used."
);
commodities[_tokenId].value = commodities[_tokenId].value.sub(_amount);
CommodityLib.Commodity memory _commodity = CommodityLib.Commodity({
category: uint64(1),
timeRegistered: uint64(now), // solium-disable-line
parentId: _tokenId,
value: _amount,
locked: false,
misc: commodities[_tokenId].misc
});
uint newCRCId = commodities.push(_commodity).sub(1);
require(newCRCId <= 18446744073709551616, "You can only split a commodity if it is within a valid index range");
if(msg.sender == IContractRegistry(contractRegistry).getLatestProxyAddr("FifoCrcMarket")) {
_transfer(ownerOf(_tokenId), _to, newCRCId);
} else {
_transfer(msg.sender, _to, newCRCId);
}
callRecipient(
msg.sender,
0x0,
_to,
newCRCId,
"",
"",
false
);
emit Split(
_to,
_amount,
uint64(newCRCId),
msg.sender,
""
);
}
}
=====================================output=====================================
pragma solidity ^0.4.24;
import "./MintableCommodity.sol";
import "../participant/ISupplier.sol";
import "../../node_modules/zeppelin-solidity/contracts//math/SafeMath.sol";
contract SplittableCommodity is MintableCommodity {
using SafeMath for uint256;
event Split(
address indexed to,
uint256 amount,
uint64 parentId,
address indexed operator,
bytes operatorData
);
function split(
uint _tokenId,
address _to,
uint256 _amount
) public whenNotPaused {
address supplierProxy = IContractRegistry(contractRegistry)
.getLatestProxyAddr("Supplier");
require(
msg.sender ==
IContractRegistry(contractRegistry).getLatestProxyAddr(
"FifoCrcMarket"
) ||
ISupplier(supplierProxy).isAllowed(this, "IMintableCommodity"),
"Splitting can only be done when both the ISplittableCommodity interface is enabled and is called by a supplier or the FifoCrcMarket is used."
);
commodities[_tokenId].value = commodities[_tokenId].value.sub(_amount);
CommodityLib.Commodity memory _commodity = CommodityLib.Commodity({
category: uint64(1),
timeRegistered: uint64(now), // solium-disable-line
parentId: _tokenId,
value: _amount,
locked: false,
misc: commodities[_tokenId].misc
});
uint newCRCId = commodities.push(_commodity).sub(1);
require(
newCRCId <= 18446744073709551616,
"You can only split a commodity if it is within a valid index range"
);
if (
msg.sender ==
IContractRegistry(contractRegistry).getLatestProxyAddr(
"FifoCrcMarket"
)
) {
_transfer(ownerOf(_tokenId), _to, newCRCId);
} else {
_transfer(msg.sender, _to, newCRCId);
}
callRecipient(msg.sender, 0x0, _to, newCRCId, "", "", false);
emit Split(_to, _amount, uint64(newCRCId), msg.sender, "");
}
}
================================================================================
`;