Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 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
@@ -1,6 +1,6 @@
{
"name": "dkg.js",
"version": "8.2.3",
"version": "8.2.4",
"description": "Javascript library for interaction with the OriginTrail Decentralized Knowledge Graph",
"main": "index.js",
"exports": {
Expand Down
19 changes: 19 additions & 0 deletions services/blockchain-service/blockchain-service-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,25 @@ export default class BlockchainServiceBase {
if (requestData?.paymaster && requestData?.paymaster !== ZERO_ADDRESS) {
// Handle the case when payer is passed
} else {
const senderBalance = await this.callContractFunction(
'Token',
'balanceOf',
[sender],
blockchain,
);

if (BigInt(senderBalance) < BigInt(requestData.tokenAmount)) {
const balance = Number(senderBalance) / 1e18;
const required = Number(requestData.tokenAmount) / 1e18;

throw new Error(
`Insufficient TRAC token balance to publish. ` +
`Wallet ${sender} has ${balance} TRAC, ` +
`but the publish operation requires ${required} TRAC. ` +
`Please fund your wallet with more TRAC tokens to proceed.`,
);
}

await this.increaseKnowledgeCollectionAllowance(
sender,
requestData.tokenAmount,
Expand Down