aboutsummaryrefslogtreecommitdiffstats
path: root/math/hs-adjunctions
diff options
context:
space:
mode:
authorKoop Mast <koop@beyonit.nl>2019-09-27 05:31:31 +0800
committerKoop Mast <koop@beyonit.nl>2019-09-27 05:31:31 +0800
commitf1fe598721f302aaea9da7c0bc01699382441608 (patch)
treecd0477bb4d85ea96e1295ac9c0cabf4f8247de88 /math/hs-adjunctions
parentc5d4cd5d5cbcd9f16aa5bd8e5fcfdc96e17a81f6 (diff)
downloadfreebsd-ports-gnome-gnome-3.36.tar.gz
freebsd-ports-gnome-gnome-3.36.tar.zst
freebsd-ports-gnome-gnome-3.36.zip
Update pango to 1.44.5.HEADgnome-3.36
Diffstat (limited to 'math/hs-adjunctions')
0 files changed, 0 insertions, 0 deletions
men <remco@wicked.ventures> 2018-06-26 00:08:49 +0800 committer Amir Bandeali <abandeali1@gmail.com> 2018-06-26 07:19:08 +0800 Compute bytes4 proxyid constants' href='/~lantw44/cgit/dexon-sol-tools/commit/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC20Proxy.sol?id=1076959006be7ad42f933e476aa75cbca17520c8'>107695900
394fbebfa
8da42b12f
394fbebfa

394fbebfa
8da42b12f









394fbebfa
8da42b12f




394fbebfa
8da42b12f







































394fbebfa
8da42b12f

























394fbebfa
394fbebfa

08ee1ab2e




8da42b12f
08ee1ab2e



78d81f193
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

















                                                                          
                        
                                 
 
                                           
                                 
 
                      
                     
 
                        
                                                                        
    
                

                
                  









                                                                                                                    
 




                                                                                                     
 







































                                                                                                  
                 

























                                                                                              
             

         




                                                                 
            



                        
 
/*

  Copyright 2018 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.4.24;
pragma experimental ABIEncoderV2;

import "../../utils/LibBytes/LibBytes.sol";
import "./MixinAuthorizable.sol";

contract ERC20Proxy is
    MixinAuthorizable
{
    // Id of this proxy.
    bytes4 constant PROXY_ID = bytes4(keccak256("ERC20Token(address)"));
    
    function () 
        external
    {
        assembly {
            // The first 4 bytes of calldata holds the function selector
            let selector := and(calldataload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000)

            // `transferFrom` will be called with the following parameters:
            // assetData Encoded byte array.
            // from Address to transfer asset from.
            // to Address to transfer asset to.
            // amount Amount of asset to transfer.
            // bytes4(keccak256("transferFrom(bytes,address,address,uint256)")) = 0xa85e59e4
            if eq(selector, 0xa85e59e400000000000000000000000000000000000000000000000000000000) {

                // To lookup a value in a mapping, we load from the storage location keccak256(k, p),
                // where k is the key left padded to 32 bytes and p is the storage slot
                let start := mload(64)
                mstore(start, and(caller, 0xffffffffffffffffffffffffffffffffffffffff))
                mstore(add(start, 32), authorized_slot)

                // Revert if authorized[msg.sender] == false
                if iszero(sload(keccak256(start, 64))) {
                    // Revert with `Error("SENDER_NOT_AUTHORIZED")`
                    mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
                    mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
                    mstore(64, 0x0000001553454e4445525f4e4f545f415554484f52495a454400000000000000)
                    mstore(96, 0)
                    revert(0, 100)
                }
                
                /////// Token contract address ///////
                // The token address is found as follows:
                // * It is stored at offset 4 in `assetData` contents.
                // * This is stored at offset 32 from `assetData`.
                // * The offset to `assetData` from Params is stored at offset
                //   4 in calldata.
                // * The offset of Params in calldata is 4.
                // So we read location 4 and add 32 + 4 + 4 to it.
                let token := calldataload(add(calldataload(4), 40))
                
                /////// Setup Header Area ///////
                // This area holds the 4-byte `transferFrom` selector.
                // Any trailing data in transferFromSelector will be
                // overwritten in the next `mstore` call.
                mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
                
                /////// Setup Params Area ///////
                // We copy the fields `from`, `to` and `amount` in bulk
                // from our own calldata to the new calldata.
                calldatacopy(4, 36, 96)

                /////// Call `token.transferFrom` using the calldata ///////
                let success := call(
                    gas,            // forward all gas
                    token,          // call address of token contract
                    0,              // don't send any ETH
                    0,              // pointer to start of input
                    100,            // length of input
                    0,              // write output over input
                    32              // output size should be 32 bytes
                )

                /////// Check return data. ///////
                // If there is no return data, we assume the token incorrectly
                // does not return a bool. In this case we expect it to revert
                // on failure, which was handled above.
                // If the token does return data, we require that it is a single
                // nonzero 32 bytes value.
                // So the transfer succeeded if the call succeeded and either
                // returned nothing, or returned a non-zero 32 byte value. 
                success := and(success, or(
                    iszero(returndatasize),
                    and(
                        eq(returndatasize, 32),
                        gt(mload(0), 0)
                    )
                ))
                if success {
                    return(0, 0)
                }
                
                // Revert with `Error("TRANSFER_FAILED")`
                mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
                mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
                mstore(64, 0x0000000f5452414e534645525f4641494c454400000000000000000000000000)
                mstore(96, 0)
                revert(0, 100)
            }
        }
    }

    /// @dev Gets the proxy id associated with the proxy address.
    /// @return Proxy id.
    function getProxyId()
        external
        pure
        returns (bytes4)
    {
        return PROXY_ID;
    }
}