public void Can_decode_array_of_dynamic_tuples() { AbiType type = new AbiArray(new AbiTuple <UserOperationAbi>()); AbiSignature signature = new AbiSignature("handleOps", type, AbiType.Address); object[] objects = _abiEncoder.Decode(AbiEncodingStyle.IncludeSignature, signature, Bytes.FromHexString("0x9984521800000000000000000000000000000000000000000000000000000000000000400000000000000000000000004173c8ce71a385e325357d8d79d6b7bc1c708f40000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000004ed7c70f96b99c776995fb64377f0d4ab3b0e1c10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000001a5b8000000000000000000000000000000000000000000000000000000000007a1200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000260000000000000000000000000fc7c490fc83e74556aa353ac360cf766e0d4313e000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084be6002c200000000000000000000000009635f643e140090a9a8dcd712ed6285858cebef0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000406661abd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041c0b5810722f6d3ff73d1e22ec2120670a6ae63ee916c026517a55754e7dd9a7b5d9b6aa5046bb35d009e034aace90845823e8365dbb22c2aa591fb60cd5c40001c00000000000000000000000000000000000000000000000000000000000000")); object[] expectedObjects = { new[] { new UserOperationAbi { Target = new Address("0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1"), Nonce = UInt256.Zero, InitCode = Bytes.Empty, CallData = Bytes.FromHexString("0xbe6002c200000000000000000000000009635f643e140090a9a8dcd712ed6285858cebef0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000406661abd00000000000000000000000000000000000000000000000000000000"), CallGas = 107960, VerificationGas = 500000, MaxFeePerGas = 0, MaxPriorityFeePerGas = 0, Paymaster = Address.Zero, PaymasterData = Bytes.Empty, Signer = new Address("0xFc7C490fc83e74556aa353ac360Cf766e0d4313e"), Signature = Bytes.FromHexString("0xc0b5810722f6d3ff73d1e22ec2120670a6ae63ee916c026517a55754e7dd9a7b5d9b6aa5046bb35d009e034aace90845823e8365dbb22c2aa591fb60cd5c40001c") } }, new Address("0x4173c8cE71a385e325357d8d79d6B7bc1c708F40") }; objects.Should().BeEquivalentTo(expectedObjects); }
public void Dynamic_array_of_uint(AbiEncodingStyle encodingStyle) { AbiType type = new AbiArray(AbiType.UInt256); AbiSignature signature = new AbiSignature("abc", type); BigInteger[] data = { 1, 2, 3 }; byte[] encoded = _abiEncoder.Encode(encodingStyle, signature, data); object[] arguments = _abiEncoder.Decode(encodingStyle, signature, encoded); Assert.AreEqual(arguments[0], data); }
public void Dynamic_array_of_string(AbiEncodingStyle encodingStyle) { AbiType type = new AbiArray(AbiType.String); AbiSignature signature = new AbiSignature("abc", type); string[] data = { "a", "bc", "def" }; byte[] encoded = _abiEncoder.Encode(encodingStyle, signature, new object[] { data }); object[] arguments = _abiEncoder.Decode(encodingStyle, signature, encoded); Assert.AreEqual(arguments[0], data); }
public void Dynamic_array_of_dynamic_array_of_uint_empty() { AbiType type = new AbiArray(new AbiArray(AbiType.UInt)); AbiSignature signature = new AbiSignature("abc", type); BigInteger[] data = { }; byte[] encoded = _abiEncoder.Encode(signature, data); object[] arguments = _abiEncoder.Decode(signature, encoded); Assert.AreEqual(arguments[0], data); }
public void Dynamic_array_of_dynamic_array_of_uint(AbiEncodingStyle encodingStyle) { AbiType type = new AbiArray(new AbiArray(AbiType.UInt256)); AbiSignature signature = new AbiSignature("abc", type); UInt256[] element = { 1, 2, 3 }; UInt256[][] data = { element, element }; byte[] encoded = _abiEncoder.Encode(encodingStyle, signature, new object[] { data }); object[] arguments = _abiEncoder.Decode(encodingStyle, signature, encoded); Assert.AreEqual(data, arguments[0]); }