public DeploymentMessageEncodingService(string defaultAddressFrom = null)
 {
     DeployContractTransactionBuilder = new DeployContractTransactionBuilder();
     ConstructorCallDecoder           = new ConstructorCallDecoder();
     ByteCodeSwarmExtractor           = new ByteCodeSwarmExtractor();
     DefaultAddressFrom = defaultAddressFrom;
 }
Ejemplo n.º 2
0
        public virtual void ShouldExtractTheAddress()
        {
            var byteCode         = "608060405234801561001057600080fd5b506040516108c73803806108c78339810160408181528251602080850151838601516060808801516080808a015160a0808c015160c0808e015160e08e018d529a8e01808e52988e018a8e01819052978e019b8d018c9052948d01958c01869052928b0182905291909a01908901819052600160a060020a038716918901919091528351939892979195929490936000916100af9183918c0190610187565b5060208281015180516100c89260018501920190610187565b50604082015180516100e4916002840191602090910190610187565b5060608201518051610100916003840191602090910190610187565b506080820151600482015560a08201518051610126916005840191602090910190610187565b5060c0919091015160069091018054600160a060020a031916600160a060020a0392831617905560405184918316907ff2a0140ebc82c8a6c5db1aaa672ed7f87fa4138e0d31c2a44275961e01d4b14590600090a350505050505050610222565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106101c857805160ff19168380011785556101f5565b828001600101855582156101f5579182015b828111156101f55782518255916020019190600101906101da565b50610201929150610205565b5090565b61021f91905b80821115610201576000815560010161020b565b90565b610696806102316000396000f30060806040526004361061004b5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416636ed2776281146100505780638418842a14610083575b600080fd5b34801561005c57600080fd5b5061008173ffffffffffffffffffffffffffffffffffffffff600435166024356102e2565b005b34801561008f57600080fd5b5061009861034f565b6040518080602001806020018060200180602001888152602001806020018773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200186810386528d818151815260200191508051906020019080838360005b8381101561011d578181015183820152602001610105565b50505050905090810190601f16801561014a5780820380516001836020036101000a031916815260200191505b5086810385528c5181528c516020918201918e019080838360005b8381101561017d578181015183820152602001610165565b50505050905090810190601f1680156101aa5780820380516001836020036101000a031916815260200191505b5086810384528b5181528b516020918201918d019080838360005b838110156101dd5781810151838201526020016101c5565b50505050905090810190601f16801561020a5780820380516001836020036101000a031916815260200191505b5086810383528a5181528a516020918201918c019080838360005b8381101561023d578181015183820152602001610225565b50505050905090810190601f16801561026a5780820380516001836020036101000a031916815260200191505b5086810382528851815288516020918201918a019080838360005b8381101561029d578181015183820152602001610285565b50505050905090810190601f1680156102ca5780820380516001836020036101000a031916815260200191505b509c5050505050505050505050505060405180910390f35b6006805473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff841690811790915560048290556040518291907ff2a0140ebc82c8a6c5db1aaa672ed7f87fa4138e0d31c2a44275961e01d4b14590600090a35050565b60045460065460008054604080516020601f6002600019600187811615610100029190910190961681900491820183900483028401830190945280835260609788978897889790968896889687969395929460039460059373ffffffffffffffffffffffffffffffffffffffff909216928991908301828280156104145780601f106103e957610100808354040283529160200191610414565b820191906000526020600020905b8154815290600101906020018083116103f757829003601f168201915b5050895460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152959c508b9450925084019050828280156104a25780601f10610477576101008083540402835291602001916104a2565b820191906000526020600020905b81548152906001019060200180831161048557829003601f168201915b5050885460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152959b508a9450925084019050828280156105305780601f1061050557610100808354040283529160200191610530565b820191906000526020600020905b81548152906001019060200180831161051357829003601f168201915b5050875460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152959a50899450925084019050828280156105be5780601f10610593576101008083540402835291602001916105be565b820191906000526020600020905b8154815290600101906020018083116105a157829003601f168201915b5050855460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529599508794509250840190508282801561064c5780601f106106215761010080835404028352916020019161064c565b820191906000526020600020905b81548152906001019060200180831161062f57829003601f168201915b505050505091509650965096509650965096509650909192939495965600a165627a7a72305820e29315e39d454420bf79c0c12899fd3031ea00b6f1d107f9285ccd34c61650ff0029";
            var expectedAddress  = "e29315e39d454420bf79c0c12899fd3031ea00b6f1d107f9285ccd34c61650ff";
            var extractedAddress = new ByteCodeSwarmExtractor().GetSwarmAddress(byteCode);

            Assert.Equal(expectedAddress, extractedAddress);
        }
 public TContractDeployment DecodeInput(TContractDeployment contractMessage, string data)
 {
     if (ByteCodeSwarmExtractor.HasSwarmAddress(data))
     {
         return(ConstructorCallDecoder.DecodeConstructorParameters <TContractDeployment>(contractMessage, data));
     }
     else // fallback to "our" bytecode..
     {
         return(ConstructorCallDecoder.DecodeConstructorParameters <TContractDeployment>(contractMessage,
                                                                                         contractMessage.ByteCode, data));
     }
 }
 public bool HasASwarmAddressTheByteCode(TContractDeployment contractMessageOuput)
 {
     return(ByteCodeSwarmExtractor.HasSwarmAddress(contractMessageOuput.ByteCode));
 }
 public string GetSwarmAddressFromByteCode(TContractDeployment contractMessageOuput)
 {
     return(ByteCodeSwarmExtractor.GetSwarmAddress(contractMessageOuput.ByteCode));
 }