mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-26 03:25:09 +00:00
Signed-off-by: Renjith K N <renjith@gmail.com>
ERC20 token review fix Signed-off-by: renjithkn@gmail.com <renjithkn@gmail.com>
This commit is contained in:
parent
0af0a83b3f
commit
1b72161da2
3 changed files with 11 additions and 11 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.example;
|
package org.example;
|
||||||
|
|
||||||
import org.hyperledger.fabric.contract.Context;
|
import org.hyperledger.fabric.contract.Context;
|
||||||
|
|
@ -35,7 +36,7 @@ public final class TokenERC20Contract implements ContractInterface {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Desc Return the name of the token - e.g. "MyToken". The original function name is `name` in
|
* @Desc: Return the name of the token - e.g. "MyToken". The original function name is `name` in
|
||||||
* ERC20 specification. However, 'name' conflicts with a parameter `name` in `Contract` class. As
|
* ERC20 specification. However, 'name' conflicts with a parameter `name` in `Contract` class. As
|
||||||
* a work around, we use `TokenName` as an alternative function name.
|
* a work around, we use `TokenName` as an alternative function name.
|
||||||
* @param ctx the transaction context
|
* @param ctx the transaction context
|
||||||
|
|
@ -188,6 +189,14 @@ public final class TokenERC20Contract implements ContractInterface {
|
||||||
.put(VALUE, valueInt).toString().getBytes(UTF_8));
|
.put(VALUE, valueInt).toString().getBytes(UTF_8));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param ctx
|
||||||
|
* @param _from
|
||||||
|
* @param _to
|
||||||
|
* @param _value
|
||||||
|
*/
|
||||||
|
|
||||||
private void doTransfer(final Context ctx, final String _from, final String _to, long _value) {
|
private void doTransfer(final Context ctx, final String _from, final String _to, long _value) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
//import org.hyperledger.fabric.samples.fabcar.TestUtil;
|
|
||||||
|
|
||||||
import org.hyperledger.fabric.protos.msp.Identities.SerializedIdentity;
|
import org.hyperledger.fabric.protos.msp.Identities.SerializedIdentity;
|
||||||
import org.hyperledger.fabric.protos.peer.ChaincodeEventPackage;
|
import org.hyperledger.fabric.protos.peer.ChaincodeEventPackage;
|
||||||
|
|
|
||||||
|
|
@ -299,15 +299,7 @@ public class TokenERC20ContractTest {
|
||||||
@Test
|
@Test
|
||||||
public void allowanceTransferFromTest() throws Exception {
|
public void allowanceTransferFromTest() throws Exception {
|
||||||
|
|
||||||
/*
|
String spender = "x509::CN=User1@org2.example.com, L=San Francisco, ST=California,"
|
||||||
* ChaincodeStub localStub = new ChaincodeStubNaiveImpl(); ((ChaincodeStubNaiveImpl)
|
|
||||||
* localStub).setCertificate(ChaincodeStubNaiveImpl.CERT_WITH_DNS); Context localCtx =
|
|
||||||
* mock(Context.class); ClientIdentity localidentity = new ClientIdentity(localStub);
|
|
||||||
* when(localCtx.getClientIdentity()).thenReturn(localidentity);
|
|
||||||
* when(localCtx.getStub()).thenReturn(localStub);
|
|
||||||
*/
|
|
||||||
|
|
||||||
String spender = "x509::CN=User1@org2.example.com, L=San Francisco, ST=California,"
|
|
||||||
+ " C=US::CN=ca.org2.example.com, O=org2.example.com, L=San Francisco, ST=California, C=US";
|
+ " C=US::CN=ca.org2.example.com, O=org2.example.com, L=San Francisco, ST=California, C=US";
|
||||||
|
|
||||||
contract.approve(ctx, spender, "200");
|
contract.approve(ctx, spender, "200");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue