Skip to content

Commit

Permalink
Merge pull request #87 from Itheum/d-david
Browse files Browse the repository at this point in the history
update dependencies + different view method for different token type (nft/sft)
  • Loading branch information
newbreedofgeek authored Jan 12, 2024
2 parents 007983e + e7fa997 commit 4428a81
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 72 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"jest": "29.7.0",
"ts-jest": "29.1.1",
"tslint": "6.1.3",
"typedoc": "0.25.4",
"typedoc": "0.25.7",
"typescript": "5.3.3"
},
"repository": {
Expand Down
73 changes: 39 additions & 34 deletions src/abis/data-nft-lease.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,36 +468,16 @@
]
},
{
"name": "getSftsFrozenForAddress",
"name": "getFrozenNonces",
"mutability": "readonly",
"inputs": [
{
"name": "address",
"type": "Address"
}
],
"inputs": [],
"outputs": [
{
"type": "variadic<u64>",
"multi_result": true
}
]
},
{
"name": "getFrozenCount",
"mutability": "readonly",
"inputs": [
{
"name": "address",
"type": "Address"
}
],
"outputs": [
{
"type": "u32"
}
]
},
{
"name": "isWhiteListEnabled",
"mutability": "readonly",
Expand Down Expand Up @@ -792,13 +772,8 @@
]
},
{
"identifier": "frozenSftsPerAddress",
"identifier": "frozenNfts",
"inputs": [
{
"name": "address",
"type": "Address",
"indexed": true
},
{
"name": "nonce",
"type": "u64",
Expand All @@ -807,13 +782,8 @@
]
},
{
"identifier": "unfrozenSftsPerAddress",
"identifier": "unfrozenNfts",
"inputs": [
{
"name": "address",
"type": "Address",
"indexed": true
},
{
"name": "nonce",
"type": "u64",
Expand Down Expand Up @@ -1040,6 +1010,41 @@
"indexed": true
}
]
},
{
"identifier": "claimRoyalties",
"inputs": [
{
"name": "claim_address",
"type": "Address",
"indexed": true
},
{
"name": "token_identifier",
"type": "EgldOrEsdtTokenIdentifier",
"indexed": true
},
{
"name": "nonce",
"type": "u64",
"indexed": true
},
{
"name": "amount",
"type": "BigUint",
"indexed": true
},
{
"name": "tax",
"type": "BigUint",
"indexed": true
},
{
"name": "tax_address",
"type": "Address",
"indexed": true
}
]
}
],
"hasCallback": true,
Expand Down
29 changes: 0 additions & 29 deletions src/minter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,35 +137,6 @@ export abstract class Minter {
}
}

/**
* Retrieves a list of nonces that are frozen for address
* @param address The address to check
*/
async viewAddressFrozenNonces(address: IAddress): Promise<number[]> {
const interaction = this.contract.methodsExplicit.getSftsFrozenForAddress([
new AddressValue(address)
]);
const query = interaction.buildQuery();
const queryResponse = await this.networkProvider.queryContract(query);
const endpointDefinition = interaction.getEndpoint();
const { firstValue, returnCode } = new ResultsParser().parseQueryResponse(
queryResponse,
endpointDefinition
);
if (returnCode.isSuccess()) {
const returnValue = firstValue?.valueOf();
const frozenNonces: number[] = returnValue.map((nonce: any) =>
nonce.toNumber()
);
return frozenNonces;
} else {
throw new ErrContractQuery(
'viewAddressFrozenNonces',
returnCode.toString()
);
}
}

/**
* Creates a `burn` transaction
* @param senderAddress the address of the user
Expand Down
23 changes: 23 additions & 0 deletions src/nft-minter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,29 @@ export class NftMinter extends Minter {
}
}

/**
* Retrieves a list of nonces that are frozen
*/
async viewFrozenNonces(): Promise<number[]> {
const interaction = this.contract.methodsExplicit.getFrozenNonces();
const query = interaction.buildQuery();
const queryResponse = await this.networkProvider.queryContract(query);
const endpointDefinition = interaction.getEndpoint();
const { firstValue, returnCode } = new ResultsParser().parseQueryResponse(
queryResponse,
endpointDefinition
);
if (returnCode.isSuccess()) {
const returnValue = firstValue?.valueOf();
const frozenNonces: number[] = returnValue.map((nonce: any) =>
nonce.toNumber()
);
return frozenNonces;
} else {
throw new ErrContractQuery('viewFrozenNonces', returnCode.toString());
}
}

/**
* Retrieves the address with update attributes roles for contract collection
*/
Expand Down
29 changes: 29 additions & 0 deletions src/sft-minter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,35 @@ export class SftMinter extends Minter {
}
}

/**
* Retrieves a list of nonces that are frozen for address
* @param address The address to check
*/
async viewAddressFrozenNonces(address: IAddress): Promise<number[]> {
const interaction = this.contract.methodsExplicit.getSftsFrozenForAddress([
new AddressValue(address)
]);
const query = interaction.buildQuery();
const queryResponse = await this.networkProvider.queryContract(query);
const endpointDefinition = interaction.getEndpoint();
const { firstValue, returnCode } = new ResultsParser().parseQueryResponse(
queryResponse,
endpointDefinition
);
if (returnCode.isSuccess()) {
const returnValue = firstValue?.valueOf();
const frozenNonces: number[] = returnValue.map((nonce: any) =>
nonce.toNumber()
);
return frozenNonces;
} else {
throw new ErrContractQuery(
'viewAddressFrozenNonces',
returnCode.toString()
);
}
}

/**
* Creates an initialize contract transaction for the contract
* @param senderAddress The address of the sender, must be the admin of the contract
Expand Down

0 comments on commit 4428a81

Please sign in to comment.