Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart contract schema support #274

Merged
merged 60 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
330112e
Working (early) implementation of serializing receive parameters.
magnusbechwind Aug 9, 2023
c308d20
early implementation of instantiating UpdateContractPayload and Invok…
magnusbechwind Aug 9, 2023
097fb72
Defined SchemaInitParameter class and function serializeInitParameter…
magnusbechwind Aug 9, 2023
5f6b0c7
Implemented functionality for SchemaInitParameter in lib.rs.
magnusbechwind Aug 10, 2023
5cc9ff0
Implemented functionality for SchemaInitParameter in lib.rs.
magnusbechwind Aug 10, 2023
a0c503f
Refactoring SchemaInitParameter and SchemaReceiveParameter into one c…
magnusbechwind Aug 16, 2023
1e25499
Remaining comments
magnusbechwind Aug 16, 2023
fc29d05
Finalized serialization of AbstractAddress.
magnusbechwind Aug 17, 2023
9b58d89
Tests and start of examples
magnusbechwind Aug 17, 2023
0f42189
Tests and start of examples
magnusbechwind Aug 17, 2023
3936bf4
Fixed bug serializing ContractAddress and AccountAddress
magnusbechwind Sep 6, 2023
37db106
Added unit tests for serializaton of AbstractAddress, AccountAddress …
magnusbechwind Sep 13, 2023
4bf974d
UInt8 wrapper and tests.
magnusbechwind Sep 15, 2023
44a42b9
Added wrappers and unit tests for AbstractAddress, AccountAddress and…
magnusbechwind Sep 15, 2023
7375a41
Added tests for ListParam
magnusbechwind Sep 15, 2023
3c7a8d3
renaming
magnusbechwind Sep 20, 2023
7ae2329
ListParam made abstract
magnusbechwind Sep 20, 2023
b20e271
Skeleton for example. All parameters (except a few wrappers needed fo…
magnusbechwind Sep 20, 2023
ce02cfc
ListParam is now abstract and needs wrapper
magnusbechwind Sep 20, 2023
b81599f
renaming
magnusbechwind Sep 20, 2023
7a41189
Updated concordium-base
magnusbechwind Sep 20, 2023
f8d5f4a
Cis2Nft example
magnusbechwind Oct 11, 2023
220fe5e
Cis2WCCD example
magnusbechwind Oct 11, 2023
a06a461
Comments
magnusbechwind Oct 11, 2023
be79f45
Final run-through of all edited files
magnusbechwind Oct 13, 2023
d31c3fa
Merge branch 'main' into smartContractSchema
magnusbechwind Oct 27, 2023
380ad5e
Cleanup after merge with main
magnusbechwind Oct 27, 2023
4a3f298
Updated CHANGELOG.md
magnusbechwind Oct 27, 2023
ab0ea34
Merge branch 'main' into smartContractSchema
magnusbechwind Nov 8, 2023
3005c98
Update concordium-sdk/src/main/java/com/concordium/sdk/transactions/s…
magnusbechwind Nov 8, 2023
b8da609
Apply suggestions from code review
magnusbechwind Nov 8, 2023
ca001df
Merge remote-tracking branch 'origin/smartContractSchema' into smartC…
magnusbechwind Nov 8, 2023
8cf10a3
Addressed review comments
magnusbechwind Nov 10, 2023
d1755c5
addressed review comments in crypto-native
magnusbechwind Nov 10, 2023
ef6a6ec
Merge branch 'main' into smartContractSchema
magnusbechwind Nov 10, 2023
c686ce6
Addressed review comments
magnusbechwind Nov 15, 2023
4ac234c
Addressed review comments
magnusbechwind Nov 15, 2023
79c07a2
Merge branch 'main' into smartContractSchema
magnusbechwind Nov 15, 2023
c3f71a2
Missing documentation
magnusbechwind Nov 15, 2023
98d3eaa
Review comments.
magnusbechwind Nov 22, 2023
67873d8
Review comments.
magnusbechwind Nov 22, 2023
75726e8
Apply suggestions from code review
magnusbechwind Nov 22, 2023
4b4e96e
waitUntilFinalized keeps trying if transaction is not found immediately.
magnusbechwind Nov 22, 2023
95093d3
Adressed review comments.
magnusbechwind Nov 24, 2023
4663817
Removed custom errors from unit test SC. Now uses predefined ParseError
magnusbechwind Nov 24, 2023
22a5f6d
Addressed review comments
magnusbechwind Nov 29, 2023
1976498
Added wait parameter to the examples to control how long to wait for …
magnusbechwind Nov 29, 2023
a4ec4fd
Apply suggestions from code review
magnusbechwind Nov 29, 2023
04b760c
Refactored waitUntilFinalized according to review comments.
magnusbechwind Nov 29, 2023
97aaf32
Fixed examples wrt. refactored waitUntilFinalized
magnusbechwind Nov 29, 2023
31b9f67
Removed UInt8 wrapper class and refactored the examples accordingly.
magnusbechwind Nov 29, 2023
093846a
Documentation cleanup
magnusbechwind Nov 29, 2023
60ca75a
Added default SchemaVersion.
magnusbechwind Dec 11, 2023
f835238
Refactored examples to use default SchemaVersion
magnusbechwind Dec 11, 2023
35ecdce
Apply suggestions from code review
magnusbechwind Dec 12, 2023
f7c2cb2
Refactored examples
magnusbechwind Dec 12, 2023
adf8ef8
Merge remote-tracking branch 'origin/smartContractSchema' into smartC…
magnusbechwind Dec 12, 2023
0f7f6f5
Cleanup of rust bindings
magnusbechwind Dec 12, 2023
5a29547
Merge branch 'main' into smartContractSchema
magnusbechwind Dec 12, 2023
c409ba0
Added rustfmt to crypto-native
magnusbechwind Dec 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Changelog

## Unreleased changes
- Implemented custom serialization of `AbstractAddress` and added class `ListParam` for conveniently using lists of objects, `AbstractAddress`, `ContractAddress` and `AccountAddress` as smart contract parameters.
magnusbechwind marked this conversation as resolved.
Show resolved Hide resolved
- Added support for creating and serializing smart contract parameters using the abstract class `SchemaParameter` and a provided `Schema`.

## 5.1.0
- Fixed a regression that made it harder to deserialize transactions from bytes.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
package com.concordium.sdk.examples.contractexample.cis2nft;

import com.concordium.sdk.ClientV2;
import com.concordium.sdk.Connection;
import com.concordium.sdk.crypto.ed25519.ED25519SecretKey;
import com.concordium.sdk.exceptions.ClientInitializationException;
import com.concordium.sdk.requests.AccountQuery;
import com.concordium.sdk.requests.BlockQuery;
import com.concordium.sdk.responses.modulelist.ModuleRef;
import com.concordium.sdk.transactions.*;
import com.concordium.sdk.transactions.smartcontracts.SchemaParameter;
import com.concordium.sdk.types.AccountAddress;
import com.concordium.sdk.types.ContractAddress;
import com.concordium.sdk.types.Nonce;
import com.concordium.sdk.types.UInt64;
import lombok.SneakyThrows;
import lombok.var;
import picocli.CommandLine;

import java.io.IOException;
import java.net.URL;
import java.util.concurrent.Callable;

/**
* Calls different methods on a <a href="https://github.com/Concordium/concordium-rust-smart-contracts/blob/main/examples/cis2-nft/src/lib.rs">cis2-nft smart contract</a> deployed on the chain.
* See {@link Cis2NftParameters} for how to create and initialize custom smart contract parameters.
* SENDER_ADDRESS, MODULE_REF, CONTRACT_ADDRESS and the key in SIGNER are dummy values and should be replaced
*/
@CommandLine.Command(name = "Cis2Nft", mixinStandardHelpOptions = true)
public class Cis2Nft implements Callable<Integer> {

private static final String SENDER_ADDRESS = "3WZE6etUvVp1eyhEtTxqZrQaanTAZnZCHEmZmDyCbCwxnmQuPE"; // Dummy address
private static final ModuleRef MODULE_REF = ModuleRef.from("247a7ac6efd2e46f72fd18741a6d1a0254ec14f95639df37079a576b2033873e"); // Dummy module ref
private static final ContractAddress CONTRACT_ADDRESS = ContractAddress.from(1, 0); // Dummy contract address

private static final Expiry EXPIRY = Expiry.createNew().addMinutes(5);

private static final TransactionSigner SIGNER = TransactionSigner.from(
SignerEntry.from(Index.from(0), Index.from(0), // TODO dummy key
ED25519SecretKey.from("56f60de843790c308dac2d59a5eec9f6b1649513f827e5a13d7038accfe31784")) // Dummy key
);

@CommandLine.Option(
names = {"-m", "--method"},
required = true,
description = "Name of method. Valid names are: ${COMPLETION-CANDIDATES}")
private Cis2NftMethod methodName;

@CommandLine.Option(
names = {"--endpoint"},
description = "GRPC interface of the node.",
defaultValue = "http://localhost:20002")
private String endpoint;

@CommandLine.Option(
names = {"--timeout"},
description = "GRPC request timeout in milliseconds.",
defaultValue = "100000")
private int timeout;


@Override
public Integer call() throws IOException, ClientInitializationException {
var endpointUrl = new URL(this.endpoint);
Connection connection = Connection.newBuilder()
.host(endpointUrl.getHost())
.port(endpointUrl.getPort())
.timeout(timeout)
.build();
var client = ClientV2.from(connection);
Nonce nonce = client.getAccountInfo(BlockQuery.BEST, AccountQuery.from(AccountAddress.from(SENDER_ADDRESS))).getAccountNonce();

switch (this.methodName) {
case INIT:
handleInit(client, nonce);
break;
case MINT:
SchemaParameter mintParams = Cis2NftParameters.generateMintParams();
handleMethod(client, nonce, mintParams);
break;
case TRANSFER:
SchemaParameter transferParams = Cis2NftParameters.generateTransferParams();
handleMethod(client, nonce, transferParams);
break;
case UPDATE_OPERATOR:
SchemaParameter updateOperatorParams = Cis2NftParameters.generateUpdateOperatorParams();
handleMethod(client, nonce, updateOperatorParams);
break;
case OPERATOR_OF:
SchemaParameter operatorOfParams = Cis2NftParameters.generateOperatorOfParams();
handleMethod(client, nonce, operatorOfParams);
break;
case BALANCE_OF:
SchemaParameter balanceOfParams = Cis2NftParameters.generateBalanceOfParams();
handleMethod(client, nonce, balanceOfParams);
break;
case TOKEN_METADATA:
SchemaParameter tokenMetadataParams = Cis2NftParameters.generateTokenMetadataParams();
handleMethod(client, nonce, tokenMetadataParams);
break;
case SUPPORTS:
SchemaParameter supportsParams = Cis2NftParameters.generateSupportsParameter();
handleMethod(client, nonce, supportsParams);
break;
case SET_IMPLEMENTORS:
SchemaParameter setImplementorsParams = Cis2NftParameters.generateSetImplementorsParams();
handleMethod(client, nonce, setImplementorsParams);
break;
}
return 0;
}

private void handleInit(ClientV2 client, Nonce nonce) {
InitName initName = InitName.from("init_cis2_nft");
InitContractPayload payload = InitContractPayload.from(CCDAmount.fromMicro(0), MODULE_REF, initName, Parameter.EMPTY);
InitContractTransaction initContractTransaction = TransactionFactory.newInitContract()
.sender(AccountAddress.from(SENDER_ADDRESS))
.payload(payload)
.expiry(EXPIRY)
.nonce(AccountNonce.from(nonce))
.signer(SIGNER)
.maxEnergyCost(UInt64.from(10000))
.build();
Hash txHash = client.sendTransaction(initContractTransaction);
System.out.println("Submitted transaction for " + this.methodName + " with hash: " + txHash);
sleep();
Hash blockHash = client.getBlockItemStatus(txHash).getFinalizedBlockItem().get().getBlockHash();
System.out.println("Transaction finalized in block with hash: " + blockHash);
}

private void handleMethod(ClientV2 client, Nonce nonce, SchemaParameter parameter) {
UpdateContract payload = UpdateContract.from(CONTRACT_ADDRESS, parameter);
UpdateContractTransaction transaction = TransactionFactory.newUpdateContract()
.sender(AccountAddress.from(SENDER_ADDRESS))
.payload(payload)
.expiry(EXPIRY)
.nonce(AccountNonce.from(nonce))
.signer(SIGNER)
.maxEnergyCost(UInt64.from(10000))
.build();
Hash txHash = client.sendTransaction(transaction);
System.out.println("Submitted transaction for " + this.methodName + " with hash: " + txHash);
sleep();
magnusbechwind marked this conversation as resolved.
Show resolved Hide resolved
Hash blockHash = client.getBlockItemStatus(txHash).getFinalizedBlockItem().get().getBlockHash();
System.out.println("Transaction finalized in block with hash: " + blockHash);
}

@SneakyThrows
private void sleep() {
for (int i = 0; i < 200; i++) {
System.out.print(".");
if (i % 50 == 0) {
System.out.println("\n");
}
Thread.sleep(30);
}
}
magnusbechwind marked this conversation as resolved.
Show resolved Hide resolved
public static void main(String[] args) {
int exitCode = new CommandLine(new Cis2Nft()).execute(args);
System.exit(exitCode);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.concordium.sdk.examples.contractexample.cis2nft;

/**
* Represents the different possible methods able to be run by {@link Cis2Nft}
*/
public enum Cis2NftMethod {
magnusbechwind marked this conversation as resolved.
Show resolved Hide resolved
INIT,
MINT,
TRANSFER,
UPDATE_OPERATOR,
OPERATOR_OF,
BALANCE_OF,
TOKEN_METADATA,
SUPPORTS,
SET_IMPLEMENTORS,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
package com.concordium.sdk.examples.contractexample.cis2nft;

import com.concordium.sdk.examples.contractexample.parameters.*;
import com.concordium.sdk.transactions.ReceiveName;
import com.concordium.sdk.transactions.smartcontracts.Schema;
import com.concordium.sdk.transactions.smartcontracts.SchemaParameter;
import com.concordium.sdk.transactions.smartcontracts.SchemaVersion;
import com.concordium.sdk.types.*;
import lombok.SneakyThrows;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

/**
* Helper class for creating and initializing parameters being used in {@link Cis2Nft}.
*/
public class Cis2NftParameters {
magnusbechwind marked this conversation as resolved.
Show resolved Hide resolved

private static final AccountAddress ACCOUNT_ADDRESS = AccountAddress.from("3XSLuJcXg6xEua6iBPnWacc3iWh93yEDMCqX8FbE3RDSbEnT9P");
private static final ContractAddress CONTRACT_ADDRESS_1 = ContractAddress.from(1, 0);
private static final ContractAddress CONTRACT_ADDRESS_2 = ContractAddress.from(2, 0);

private static final String CIS_2_NFT_CONTRACT_NAME = "cis2_nft";

@SneakyThrows
public static SchemaParameter generateMintParams() {
Schema schema = Schema.from(Files.readAllBytes(Paths.get("./src/main/java/com/concordium/sdk/examples/contractexample/cis2nft/cis2-nft.schema.bin")), SchemaVersion.V3);
ReceiveName mintParamsReceiveName = ReceiveName.from(CIS_2_NFT_CONTRACT_NAME, "mint");
List<TokenIdU32> tokens = new ArrayList<>();
tokens.add(TokenIdU32.from(2));
tokens.add(TokenIdU32.from(22));
tokens.add(TokenIdU32.from(2132));
SchemaParameter mintParameter = new MintParams(schema, mintParamsReceiveName, ACCOUNT_ADDRESS, tokens);
mintParameter.initialize(true);
return mintParameter;
}

@SneakyThrows
public static SchemaParameter generateTransferParams() {
magnusbechwind marked this conversation as resolved.
Show resolved Hide resolved
Schema schema = Schema.from(Files.readAllBytes(Paths.get("./src/main/java/com/concordium/sdk/examples/contractexample/cis2nft/cis2-nft.schema.bin")), SchemaVersion.V3);
ReceiveName nftTransferReceiveName = ReceiveName.from(CIS_2_NFT_CONTRACT_NAME, "transfer");
TokenIdU32 tokenId = TokenIdU32.from(12);
TokenAmountU8 amount = TokenAmountU8.from(1);
AbstractAddress from = CONTRACT_ADDRESS_1;
Receiver to = new Receiver(CONTRACT_ADDRESS_2, "mint");
List<UInt8> data = new ArrayList<>();
data.add(UInt8.from(123));
data.add(UInt8.from(23));
NftTransfer transfer = new NftTransfer(tokenId, amount, from, to, data);
List<NftTransfer> transfers = new ArrayList<>();
transfers.add(transfer);
SchemaParameter transferParameter = new NftTransferParam(schema, nftTransferReceiveName, transfers);
transferParameter.initialize(true);

return transferParameter;
}

@SneakyThrows
magnusbechwind marked this conversation as resolved.
Show resolved Hide resolved
public static SchemaParameter generateUpdateOperatorParams() {
Schema schema = Schema.from(Files.readAllBytes(Paths.get("./src/main/java/com/concordium/sdk/examples/contractexample/cis2nft/cis2-nft.schema.bin")), SchemaVersion.V3);
ReceiveName updateOperatorReceiveName = ReceiveName.from(CIS_2_NFT_CONTRACT_NAME, "updateOperator");
UpdateOperator update1 = new UpdateOperator(UpdateOperator.OperatorUpdate.ADD, ACCOUNT_ADDRESS);
UpdateOperator update2 = new UpdateOperator(UpdateOperator.OperatorUpdate.REMOVE, CONTRACT_ADDRESS_1);
List<UpdateOperator> updateOperatorList = new ArrayList<>();
updateOperatorList.add(update1);
updateOperatorList.add(update2);
SchemaParameter updateOperatorsParams = new UpdateOperatorParams(schema, updateOperatorReceiveName, updateOperatorList);
updateOperatorsParams.initialize(true);

return updateOperatorsParams;
}

public static SchemaParameter generateOperatorOfParams() throws IOException {
magnusbechwind marked this conversation as resolved.
Show resolved Hide resolved
Schema schema = Schema.from(Files.readAllBytes(Paths.get("./src/main/java/com/concordium/sdk/examples/contractexample/cis2nft/cis2-nft.schema.bin")), SchemaVersion.V3);
ReceiveName operatorOfReceiveName = ReceiveName.from(CIS_2_NFT_CONTRACT_NAME, "operatorOf");
OperatorOfQuery operatorOfQuery1 = new OperatorOfQuery(ACCOUNT_ADDRESS, CONTRACT_ADDRESS_1);
OperatorOfQuery operatorOfQuery2 = new OperatorOfQuery(CONTRACT_ADDRESS_1, CONTRACT_ADDRESS_2);
List<OperatorOfQuery> operatorOfQueries = new ArrayList<>();
operatorOfQueries.add(operatorOfQuery1);
operatorOfQueries.add(operatorOfQuery2);
SchemaParameter operatorOfQueryParams = new OperatorOfQueryParams(schema, operatorOfReceiveName, operatorOfQueries);
operatorOfQueryParams.initialize(true);
return operatorOfQueryParams;
}

public static SchemaParameter generateBalanceOfParams() throws IOException {
Schema schema = Schema.from(Files.readAllBytes(Paths.get("./src/main/java/com/concordium/sdk/examples/contractexample/cis2nft/cis2-nft.schema.bin")), SchemaVersion.V3);
ReceiveName balanceOfReceiveName = ReceiveName.from(CIS_2_NFT_CONTRACT_NAME, "balanceOf");
NftBalanceOfQuery balanceOfQuery1 = new NftBalanceOfQuery(TokenIdU32.from(22222), ACCOUNT_ADDRESS);
NftBalanceOfQuery balanceOfQuery2 = new NftBalanceOfQuery(TokenIdU32.from(42), CONTRACT_ADDRESS_1);
List<NftBalanceOfQuery> balanceOfQueries = new ArrayList<>();
balanceOfQueries.add(balanceOfQuery1);
balanceOfQueries.add(balanceOfQuery2);
SchemaParameter contractBalanceOfQueryParams = new NftBalanceOfQueryParams(schema, balanceOfReceiveName, balanceOfQueries);
contractBalanceOfQueryParams.initialize(true);
return contractBalanceOfQueryParams;
}

public static SchemaParameter generateTokenMetadataParams() throws IOException {
Schema schema = Schema.from(Files.readAllBytes(Paths.get("./src/main/java/com/concordium/sdk/examples/contractexample/cis2nft/cis2-nft.schema.bin")), SchemaVersion.V3);
ReceiveName tokenMetadataReceiveName = ReceiveName.from(CIS_2_NFT_CONTRACT_NAME, "tokenMetadata");
TokenIdU32 token1 = TokenIdU32.from(21);
TokenIdU32 token2 = TokenIdU32.from(22);
List<TokenIdU32> tokensForMetadataQuery = new ArrayList<>();
tokensForMetadataQuery.add(token1);
tokensForMetadataQuery.add(token2);
SchemaParameter nftMetaDataQuery = new NftMetaDataQuery(schema, tokenMetadataReceiveName, tokensForMetadataQuery);
nftMetaDataQuery.initialize(true);
return nftMetaDataQuery;
}

public static SchemaParameter generateSupportsParameter() throws IOException {
Schema schema = Schema.from(Files.readAllBytes(Paths.get("./src/main/java/com/concordium/sdk/examples/contractexample/cis2nft/cis2-nft.schema.bin")), SchemaVersion.V3);
ReceiveName supportsReceiveName = ReceiveName.from(CIS_2_NFT_CONTRACT_NAME, "supports");
String standardIdentifier1 = "identifier1";
String standardIdentifier2 = "identifier2";
List<String> identifiers = new ArrayList<>();
identifiers.add(standardIdentifier1);
identifiers.add(standardIdentifier2);
SchemaParameter supportsQueryParams = new SupportsQueryParams(schema, supportsReceiveName, identifiers);
supportsQueryParams.initialize(true);
return supportsQueryParams;
}

public static SchemaParameter generateSetImplementorsParams() throws IOException {
Schema schema = Schema.from(Files.readAllBytes(Paths.get("./src/main/java/com/concordium/sdk/examples/contractexample/cis2nft/cis2-nft.schema.bin")), SchemaVersion.V3);
ReceiveName setImplementorsReceiveName = ReceiveName.from(CIS_2_NFT_CONTRACT_NAME, "setImplementors");
List<ContractAddress> implementors = new ArrayList<>();
String identifier = "IdentifierID";
implementors.add(CONTRACT_ADDRESS_1);
implementors.add(CONTRACT_ADDRESS_2);
SchemaParameter setImplementorsParams = new SetImplementorsParams(schema, setImplementorsReceiveName, identifier, implementors);
setImplementorsParams.initialize();
return setImplementorsParams;
}

magnusbechwind marked this conversation as resolved.
Show resolved Hide resolved
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.concordium.sdk.examples.contractexample.parameters;

import com.concordium.sdk.types.AbstractAddress;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* Represents a '<a href = "https://github.com/Concordium/concordium-rust-smart-contracts/blob/main/concordium-cis2/src/lib.rs#L1138">BalanceOfQuery</a>' used in different smart contracts
*/
@Getter
@AllArgsConstructor
public class BalanceOfQuery<T extends TokenId> {
@JsonProperty("token_id")
private T tokenId;
magnusbechwind marked this conversation as resolved.
Show resolved Hide resolved
@JsonSerialize(using = AbstractAddress.AbstractAddressJsonSerializer.class)
private AbstractAddress address;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.concordium.sdk.examples.contractexample.parameters;

import com.concordium.sdk.transactions.ReceiveName;
import com.concordium.sdk.transactions.smartcontracts.Schema;
import com.concordium.sdk.transactions.smartcontracts.SchemaParameter;
import com.concordium.sdk.types.AbstractAddress;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter;

import java.util.List;

/**
* Represents the parameter 'MintParams' in the <a href="https://github.com/Concordium/concordium-rust-smart-contracts/blob/main/examples/cis2-nft/src/lib.rs#L49">cis2-nft example</a>
* Used with contract function 'mint' which mints a number of tokens to a given {@link AbstractAddress}.
*/
@Getter
public class MintParams extends SchemaParameter {

/**
* Owner of the newly minted tokens.
*/
@JsonSerialize(using = AbstractAddress.AbstractAddressJsonSerializer.class)
private final AbstractAddress owner;
/**
* A collection of tokens to mint.
*/
private final List<TokenIdU32> tokens;

public MintParams(Schema schema, ReceiveName receiveName, AbstractAddress owner, List<TokenIdU32> tokens) {
super(schema, receiveName);
this.owner = owner;
this.tokens = tokens;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.concordium.sdk.examples.contractexample.parameters;

import com.concordium.sdk.types.AbstractAddress;

/**
* Wrapper class for {@link BalanceOfQuery} enforcing the correct Token id for cis2-nft contract.
*/
public class NftBalanceOfQuery extends BalanceOfQuery<TokenIdU32> {

public NftBalanceOfQuery(TokenIdU32 tokenId, AbstractAddress address) {
super(tokenId, address);
}
}
Loading
Loading