|
23030 | 23030 | ] |
23031 | 23031 | ] |
23032 | 23032 | }, |
23033 | | - "ExtractBeneficiaryId": { |
23034 | | - "main": [ |
23035 | | - [ |
23036 | | - { |
23037 | | - "index": 0, |
23038 | | - "node": "GetTodayTransfers", |
23039 | | - "type": "main" |
23040 | | - } |
23041 | | - ] |
23042 | | - ] |
23043 | | - }, |
23044 | 23033 | "Get Capability": { |
23045 | 23034 | "main": [ |
23046 | 23035 | [ |
|
23052 | 23041 | ] |
23053 | 23042 | ] |
23054 | 23043 | }, |
23055 | | - "Get NFT": { |
23056 | | - "main": [ |
23057 | | - [ |
23058 | | - { |
23059 | | - "index": 0, |
23060 | | - "node": "ExtractBeneficiaryId", |
23061 | | - "type": "main" |
23062 | | - } |
23063 | | - ] |
23064 | | - ] |
23065 | | - }, |
23066 | 23044 | "GetCaller1": { |
23067 | 23045 | "main": [ |
23068 | 23046 | [ |
|
23235 | 23213 | [ |
23236 | 23214 | { |
23237 | 23215 | "index": 0, |
23238 | | - "node": "Get NFT", |
| 23216 | + "node": "GetTodayTransfers", |
23239 | 23217 | "type": "main" |
23240 | 23218 | } |
23241 | 23219 | ], |
|
23424 | 23402 | [ |
23425 | 23403 | { |
23426 | 23404 | "index": 0, |
23427 | | - "node": "Get NFT", |
| 23405 | + "node": "GetTodayTransfers", |
23428 | 23406 | "type": "main" |
23429 | 23407 | } |
23430 | 23408 | ] |
@@ -23705,12 +23683,12 @@ |
23705 | 23683 | "parameters": { |
23706 | 23684 | "operation": "executeQuery", |
23707 | 23685 | "options": { |
23708 | | - "queryReplacement": "={{ $json.agent_beneficiary_account_id }}" |
| 23686 | + "queryReplacement": "={{ $json.beneficiary_account_id }}" |
23709 | 23687 | }, |
23710 | 23688 | "query": "select string_agg(amount, ',') as amounts\nfrom \"default\".reward_history\nwhere recipient_account_id = $1 and created_at >= now()::date" |
23711 | 23689 | }, |
23712 | 23690 | "position": [ |
23713 | | - 1680, |
| 23691 | + 1280, |
23714 | 23692 | -60 |
23715 | 23693 | ], |
23716 | 23694 | "type": "n8n-nodes-base.postgres", |
|
23724 | 23702 | "mode": "runOnceForEachItem" |
23725 | 23703 | }, |
23726 | 23704 | "position": [ |
23727 | | - 1860, |
| 23705 | + 1580, |
23728 | 23706 | -60 |
23729 | 23707 | ], |
23730 | 23708 | "type": "n8n-nodes-base.code", |
|
23737 | 23715 | "jsCode": "const rewardsPerDay = BigInt($('SumBigInts').first().json.total)\nconst maxRewardsPerDay = BigInt($('GetVariables').first().json.max_usage_reward_amount)\n\nreturn [{\n json: {\n shouldBeRewarded: rewardsPerDay < maxRewardsPerDay\n }\n}]" |
23738 | 23716 | }, |
23739 | 23717 | "position": [ |
23740 | | - 2040, |
| 23718 | + 1900, |
23741 | 23719 | -60 |
23742 | 23720 | ], |
23743 | 23721 | "type": "n8n-nodes-base.code", |
|
23765 | 23743 | "parameters": { |
23766 | 23744 | "amount": "={{ $('GetVariables').item.json.usage_reward_amount }}", |
23767 | 23745 | "privateKey": "={{ $('GetVariables').item.json.reward_account_private_key }}", |
23768 | | - "recipientId": "={{ $('ExtractBeneficiaryId').item.json.agent_beneficiary_account_id }}", |
| 23746 | + "recipientId": "={{ $('IsNftIssued?').item.json.beneficiary_account_id }}", |
23769 | 23747 | "senderId": "={{ $('GetVariables').item.json.reward_account_id }}" |
23770 | 23748 | }, |
23771 | 23749 | "position": [ |
|
23790 | 23768 | "message_thread_id": "={{ $('GetVariables').item.json.telegram_monitoring_topic_id }}" |
23791 | 23769 | }, |
23792 | 23770 | "chatId": "={{ $('GetVariables').item.json.telegram_monitoring_chat_id }}", |
23793 | | - "text": "=Agent beneficiary {{ $json.recipient_account_id }} rewarded for agent usage\nTx: https://nearblocks.io/txns/{{ $('Transfer NEAR').item.json.result.transaction_outcome.id }}\nCaller: @{{ $('Loop Over Items').item.json.caller_username }}\nRequest: {{ $('Loop Over Items').item.json.execution_input }}" |
| 23771 | + "text": "=Agent beneficiary {{ $('IsNftIssued?').item.json.beneficiary_account_id }} rewarded for agent usage\nTx: https://nearblocks.io/txns/{{ $('Transfer NEAR').item.json.result.transaction_outcome.id }}\nCaller: @{{ $('Loop Over Items').item.json.caller_username }}\nRequest: {{ $('Loop Over Items').item.json.execution_input }}" |
23794 | 23772 | }, |
23795 | 23773 | "position": [ |
23796 | 23774 | 3000, |
|
23815 | 23793 | "message_thread_id": "={{ $('GetVariables').item.json.telegram_monitoring_topic_id }}" |
23816 | 23794 | }, |
23817 | 23795 | "chatId": "={{ $('GetVariables').item.json.telegram_monitoring_chat_id }}", |
23818 | | - "text": "=Cannot reward {{ $json.recipient_account_id }} for agent usage\nCaller: @{{ $('Loop Over Items').item.json.caller_username }}\nRequest: {{ $('Loop Over Items').item.json.execution_input }}" |
| 23796 | + "text": "=Cannot reward {{ $('IsNftIssued?').item.json.beneficiary_account_id }} for agent usage\nCaller: @{{ $('Loop Over Items').item.json.caller_username }}\nRequest: {{ $('Loop Over Items').item.json.execution_input }}" |
23819 | 23797 | }, |
23820 | 23798 | "position": [ |
23821 | 23799 | 2720, |
|
23854 | 23832 | } |
23855 | 23833 | }, |
23856 | 23834 | "position": [ |
23857 | | - 2240, |
| 23835 | + 2200, |
23858 | 23836 | -60 |
23859 | 23837 | ], |
23860 | 23838 | "type": "n8n-nodes-base.if", |
|
23948 | 23926 | ], |
23949 | 23927 | "value": { |
23950 | 23928 | "amount": "={{ $('GetVariables').item.json.usage_reward_amount }}", |
23951 | | - "recipient_account_id": "={{ $('ExtractBeneficiaryId').item.json.agent_beneficiary_account_id }}", |
| 23929 | + "recipient_account_id": "={{ $('IsNftIssued?').item.json.beneficiary_account_id }}", |
23952 | 23930 | "related_item_id": "={{ $('Loop Over Items').item.json.id }}", |
23953 | 23931 | "related_item_type": "usage-owner", |
23954 | 23932 | "tx_hash": "={{ $json.result.transaction_outcome.id }}" |
|
25545 | 25523 | "removed": false, |
25546 | 25524 | "required": false, |
25547 | 25525 | "type": "string" |
| 25526 | + }, |
| 25527 | + { |
| 25528 | + "canBeUsedToMatch": true, |
| 25529 | + "defaultMatch": false, |
| 25530 | + "display": true, |
| 25531 | + "displayName": "beneficiary_account_id", |
| 25532 | + "id": "beneficiary_account_id", |
| 25533 | + "removed": false, |
| 25534 | + "required": false, |
| 25535 | + "type": "string" |
| 25536 | + }, |
| 25537 | + { |
| 25538 | + "canBeUsedToMatch": true, |
| 25539 | + "defaultMatch": false, |
| 25540 | + "display": true, |
| 25541 | + "displayName": "beneficiary_network", |
| 25542 | + "id": "beneficiary_network", |
| 25543 | + "removed": false, |
| 25544 | + "required": false, |
| 25545 | + "type": "string" |
25548 | 25546 | } |
25549 | 25547 | ], |
25550 | 25548 | "value": { |
| 25549 | + "beneficiary_account_id": "={{$('GetCapability').item.json.name.split('/')[0]}}", |
| 25550 | + "beneficiary_network": "near", |
25551 | 25551 | "id": "={{ $('Loop Over Items').item.json.capability_id }}", |
25552 | 25552 | "token_id": "={{ $('SetTokenId').item.json.token_id }}" |
25553 | 25553 | } |
|
25593 | 25593 | "type": "@dapplets/n8n-nodes-near-protocol.writeContractCall", |
25594 | 25594 | "typeVersion": 1 |
25595 | 25595 | }, |
25596 | | - { |
25597 | | - "id": "e016402c-195f-4c9d-997b-a14253a65724", |
25598 | | - "name": "Get NFT", |
25599 | | - "parameters": { |
25600 | | - "contractId": "={{ $('GetVariables').item.json.nft_contract_id }}", |
25601 | | - "methodArgs": "={{ JSON.stringify({ \n token_id: $json.token_id\n}) }}", |
25602 | | - "methodName": "nft_token" |
25603 | | - }, |
25604 | | - "position": [ |
25605 | | - 1280, |
25606 | | - -60 |
25607 | | - ], |
25608 | | - "type": "@dapplets/n8n-nodes-near-protocol.viewContractCall", |
25609 | | - "typeVersion": 1 |
25610 | | - }, |
25611 | 25596 | { |
25612 | 25597 | "id": "d8399d46-273a-4725-9234-5546944a1869", |
25613 | 25598 | "name": "SetTokenId", |
|
25632 | 25617 | "type": "n8n-nodes-base.set", |
25633 | 25618 | "typeVersion": 3.4 |
25634 | 25619 | }, |
25635 | | - { |
25636 | | - "id": "d609e9f5-8653-41d0-a6b1-4ee34f975379", |
25637 | | - "name": "ExtractBeneficiaryId", |
25638 | | - "parameters": { |
25639 | | - "assignments": { |
25640 | | - "assignments": [ |
25641 | | - { |
25642 | | - "id": "63dd2cde-dbda-4a0f-8741-c7b5b6063f46", |
25643 | | - "name": "agent_beneficiary_account_id", |
25644 | | - "type": "string", |
25645 | | - "value": "={{ JSON.parse($json.result.metadata.extra).beneficiary_account_id }}" |
25646 | | - } |
25647 | | - ] |
25648 | | - }, |
25649 | | - "options": { |
25650 | | - } |
25651 | | - }, |
25652 | | - "position": [ |
25653 | | - 1480, |
25654 | | - -60 |
25655 | | - ], |
25656 | | - "type": "n8n-nodes-base.set", |
25657 | | - "typeVersion": 3.4 |
25658 | | - }, |
25659 | 25620 | { |
25660 | 25621 | "credentials": { |
25661 | 25622 | "telegramApi": { |
|
25829 | 25790 | "tags": [ |
25830 | 25791 | ], |
25831 | 25792 | "triggerCount": 1, |
25832 | | - "updatedAt": "2025-06-02T16:39:01.000Z", |
25833 | | - "versionId": "de216523-c5aa-4633-9abb-1103c27520e7" |
| 25793 | + "updatedAt": "2025-06-03T10:46:07.000Z", |
| 25794 | + "versionId": "be399525-e8ef-4574-98b5-f55a5de9a621" |
25834 | 25795 | }, |
25835 | 25796 | { |
25836 | 25797 | "active": false, |
|
0 commit comments