@subql/node-algorand 4.0.3 → 4.0.4-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/algorand/utils.algorand.js +1 -1
- package/dist/algorand/utils.algorand.js.map +1 -1
- package/package.json +7 -6
- package/dist/algorand/algorand.spec.d.ts +0 -3
- package/dist/algorand/algorand.spec.js +0 -134
- package/dist/algorand/algorand.spec.js.map +0 -1
- package/dist/algorand/utils.algorand.spec.d.ts +0 -1
- package/dist/algorand/utils.algorand.spec.js +0 -66
- package/dist/algorand/utils.algorand.spec.js.map +0 -1
- package/dist/indexer/api.service.spec.d.ts +0 -1
- package/dist/indexer/api.service.spec.js +0 -70
- package/dist/indexer/api.service.spec.js.map +0 -1
- package/dist/indexer/dictionary/v1/algorandDictionaryV1.spec.d.ts +0 -1
- package/dist/indexer/dictionary/v1/algorandDictionaryV1.spec.js +0 -98
- package/dist/indexer/dictionary/v1/algorandDictionaryV1.spec.js.map +0 -1
|
@@ -11,7 +11,7 @@ function algorandBlockToHeader(block) {
|
|
|
11
11
|
blockHeight: block.round,
|
|
12
12
|
blockHash: block.hash,
|
|
13
13
|
parentHash: block.previousBlockHash,
|
|
14
|
-
timestamp: new Date(block.timestamp),
|
|
14
|
+
timestamp: new Date(block.timestamp * 1000), // Add MS
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
exports.algorandBlockToHeader = algorandBlockToHeader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.algorand.js","sourceRoot":"","sources":["../../src/algorand/utils.algorand.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAEnC,gDAAwE;AAOxE,qCAAmD;AACnD,mCAAwC;AAIxC,SAAgB,qBAAqB,CAAC,KAAmB;IACvD,OAAO;QACL,WAAW,EAAE,KAAK,CAAC,KAAK;QACxB,SAAS,EAAE,KAAK,CAAC,IAAI;QACr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CAAC,CACpD,EACD;YACA,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAvBD,8CAuBC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { filterBlockTimestamp, Header, IBlock } from '@subql/node-core';\nimport {\n AlgorandBlock,\n AlgorandBlockFilter,\n AlgorandTransaction,\n AlgorandTransactionFilter,\n} from '@subql/types-algorand';\nimport { Indexer, TransactionType } from 'algosdk';\nimport { camelCase, get } from 'lodash';\nimport { SubqlProjectBlockFilter } from '../configure/SubqueryProject';\nimport { BlockContent } from '../indexer/types';\n\nexport function algorandBlockToHeader(block: BlockContent): Header {\n return {\n blockHeight: block.round,\n blockHash: block.hash,\n parentHash: block.previousBlockHash,\n timestamp: new Date(block.timestamp * 1000), // Add MS\n };\n}\n\nexport function formatBlockUtil<B extends AlgorandBlock = AlgorandBlock>(\n block: B,\n): IBlock<B> {\n return {\n block,\n getHeader: () => algorandBlockToHeader(block),\n };\n}\n\nexport function camelCaseObjectKey(object: object) {\n if (Array.isArray(object)) {\n return object.map((v) => camelCaseObjectKey(v));\n } else if (object !== null && object.constructor === Object) {\n return Object.keys(object).reduce(\n (result, key) => ({\n ...result,\n [camelCase(key)]: camelCaseObjectKey(object[key]),\n }),\n {},\n );\n }\n\n return object;\n}\n\nexport function calcInterval(api: Indexer): number {\n // Pulled from https://metrics.algorand.org/#/protocol/#blocks\n return 3300;\n}\n\nexport const mappingFilterTransaction = {\n [TransactionType.pay]: {\n sender: 'sender',\n receiver: 'paymentTransaction.receiver',\n },\n [TransactionType.keyreg]: {\n nonParticipant: 'keyregTransaction.nonParticipation',\n sender: 'sender',\n },\n [TransactionType.acfg]: {\n assetId: 'assetConfigTransaction.assetId',\n sender: 'sender',\n },\n [TransactionType.axfer]: {\n assetId: 'assetTransferTransaction.assetId',\n sender: 'sender',\n receiver: 'assetTransferTransaction.receiver',\n },\n [TransactionType.afrz]: {\n assetId: 'assetFreezeTransaction.assetId',\n newFreezeStatus: 'assetFreezeTransaction.newFreezeStatus',\n address: 'sender',\n },\n [TransactionType.appl]: {\n applicationId: 'applicationTransaction.applicationId',\n applicationArgs: 'applicationTransaction.applicationArgs',\n sender: 'sender',\n },\n};\n\nexport function filterBlock(\n block: AlgorandBlock,\n filter?: AlgorandBlockFilter,\n): boolean {\n if (!filter) return true;\n if (!filterBlockModulo(block, filter)) return false;\n if (\n !filterBlockTimestamp(block.timestamp, filter as SubqlProjectBlockFilter)\n ) {\n return false;\n }\n // no filters for block.\n return true;\n}\n\nexport function filterBlockModulo(\n block: AlgorandBlock,\n filter: AlgorandBlockFilter,\n): boolean {\n const { modulo } = filter;\n if (!modulo) return true;\n return block.round % modulo === 0;\n}\n\nfunction txComparator(filter: any, data: any): boolean {\n if (Array.isArray(filter)) {\n for (let i = 0; i < filter.length; i++) {\n const valFilter = filter[i];\n const valData = data[i];\n\n if (valFilter === null) {\n continue;\n }\n\n if (valFilter !== valData) {\n return false;\n }\n }\n return true;\n }\n\n return filter === data;\n}\n\nexport function filterTransaction(\n txn: AlgorandTransaction,\n filter?: AlgorandTransactionFilter,\n): boolean {\n if (!filter) return true;\n const { txType, ...filterByKey } = filter;\n\n if (txType && txn.txType !== txType) return false;\n\n for (const key in filterByKey) {\n if (\n mappingFilterTransaction[txn.txType] &&\n filterByKey[key] !== undefined &&\n !txComparator(\n filterByKey[key],\n get(txn, mappingFilterTransaction[txn.txType][key]),\n )\n ) {\n return false;\n }\n }\n\n return true;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subql/node-algorand",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4-1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Ian He",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"@nestjs/event-emitter": "^2.0.0",
|
|
25
25
|
"@nestjs/platform-express": "^11.0.10",
|
|
26
26
|
"@nestjs/schedule": "^5.0.1",
|
|
27
|
-
"@subql/common": "^5.
|
|
28
|
-
"@subql/common-algorand": "4.4.
|
|
29
|
-
"@subql/node-core": "^18.
|
|
30
|
-
"@subql/types-algorand": "4.1.
|
|
27
|
+
"@subql/common": "^5.8.0",
|
|
28
|
+
"@subql/common-algorand": "4.4.4-0",
|
|
29
|
+
"@subql/node-core": "^18.5.0",
|
|
30
|
+
"@subql/types-algorand": "4.1.2-0",
|
|
31
31
|
"algosdk": "^2.8.0",
|
|
32
32
|
"lodash": "^4.17.21",
|
|
33
33
|
"reflect-metadata": "^0.1.13",
|
|
@@ -62,5 +62,6 @@
|
|
|
62
62
|
"README.md",
|
|
63
63
|
"CHANGELOG.md",
|
|
64
64
|
"LICENSE"
|
|
65
|
-
]
|
|
65
|
+
],
|
|
66
|
+
"stableVersion": "4.0.4-0"
|
|
66
67
|
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
3
|
-
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.prepareApiService = void 0;
|
|
6
|
-
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
7
|
-
const testing_1 = require("@nestjs/testing");
|
|
8
|
-
const node_core_1 = require("@subql/node-core");
|
|
9
|
-
const graphql_1 = require("graphql");
|
|
10
|
-
const algorand_1 = require("../algorand");
|
|
11
|
-
const mainnetEndpoint = 'https://mainnet-idx.algonode.cloud/';
|
|
12
|
-
const testnetEndpoint = 'https://testnet-idx.algonode.cloud';
|
|
13
|
-
const mainnetChainId = 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=';
|
|
14
|
-
const testnetChainId = 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=';
|
|
15
|
-
function testSubqueryProject(endpoint, chainId) {
|
|
16
|
-
return {
|
|
17
|
-
network: {
|
|
18
|
-
chainId,
|
|
19
|
-
endpoint: [endpoint],
|
|
20
|
-
dictionary: `https://api.subquery.network/sq/subquery/Algorand-Dictionary`,
|
|
21
|
-
},
|
|
22
|
-
dataSources: [],
|
|
23
|
-
id: 'test',
|
|
24
|
-
root: './',
|
|
25
|
-
schema: new graphql_1.GraphQLSchema({}),
|
|
26
|
-
templates: [],
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
// eslint-disable-next-line jest/no-export
|
|
30
|
-
const prepareApiService = async (endpoint = mainnetEndpoint, chainId = mainnetChainId) => {
|
|
31
|
-
const module = await testing_1.Test.createTestingModule({
|
|
32
|
-
providers: [
|
|
33
|
-
{
|
|
34
|
-
provide: 'ISubqueryProject',
|
|
35
|
-
useFactory: () => testSubqueryProject(endpoint, chainId),
|
|
36
|
-
},
|
|
37
|
-
node_core_1.NodeConfig,
|
|
38
|
-
node_core_1.ConnectionPoolStateManager,
|
|
39
|
-
node_core_1.ConnectionPoolService,
|
|
40
|
-
{
|
|
41
|
-
provide: algorand_1.AlgorandApiService,
|
|
42
|
-
useFactory: algorand_1.AlgorandApiService.init,
|
|
43
|
-
inject: ['ISubqueryProject', node_core_1.ConnectionPoolService, event_emitter_1.EventEmitter2],
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
imports: [event_emitter_1.EventEmitterModule.forRoot()],
|
|
47
|
-
}).compile();
|
|
48
|
-
const app = module.createNestApplication();
|
|
49
|
-
await app.init();
|
|
50
|
-
const apiService = app.get(algorand_1.AlgorandApiService);
|
|
51
|
-
return [app, apiService];
|
|
52
|
-
};
|
|
53
|
-
exports.prepareApiService = prepareApiService;
|
|
54
|
-
jest.setTimeout(90000);
|
|
55
|
-
describe('Algorand RPC', () => {
|
|
56
|
-
let app;
|
|
57
|
-
let apiService;
|
|
58
|
-
afterEach(() => {
|
|
59
|
-
return app?.close();
|
|
60
|
-
});
|
|
61
|
-
it('Can filter acfg with sender', () => {
|
|
62
|
-
const tx = {
|
|
63
|
-
assetConfigTransaction: {
|
|
64
|
-
assetId: 0,
|
|
65
|
-
params: {
|
|
66
|
-
clawback: '7JMGBIDKQRR4MC3DNC73QU4QUNNN43VNY5RYPN2FRWEG6NXAHQMCPD4BIQ',
|
|
67
|
-
creator: '7JMGBIDKQRR4MC3DNC73QU4QUNNN43VNY5RYPN2FRWEG6NXAHQMCPD4BIQ',
|
|
68
|
-
decimals: 0,
|
|
69
|
-
defaultFrozen: false,
|
|
70
|
-
freeze: '7JMGBIDKQRR4MC3DNC73QU4QUNNN43VNY5RYPN2FRWEG6NXAHQMCPD4BIQ',
|
|
71
|
-
manager: '7JMGBIDKQRR4MC3DNC73QU4QUNNN43VNY5RYPN2FRWEG6NXAHQMCPD4BIQ',
|
|
72
|
-
name: 'flowTest.algo',
|
|
73
|
-
nameB64: 'Zmxvd1Rlc3QuYWxnbw==',
|
|
74
|
-
reserve: '7JMGBIDKQRR4MC3DNC73QU4QUNNN43VNY5RYPN2FRWEG6NXAHQMCPD4BIQ',
|
|
75
|
-
total: 1,
|
|
76
|
-
unitName: 'xAns',
|
|
77
|
-
unitNameB64: 'eEFucw==',
|
|
78
|
-
url: 'https://xgov.app',
|
|
79
|
-
urlB64: 'aHR0cHM6Ly94Z292LmFwcA==',
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
closeRewards: 0,
|
|
83
|
-
closingAmount: 0,
|
|
84
|
-
confirmedRound: 27081666,
|
|
85
|
-
createdAssetIndex: 154583116,
|
|
86
|
-
fee: 1000,
|
|
87
|
-
firstValid: 27081664,
|
|
88
|
-
genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
|
|
89
|
-
genesisId: 'testnet-v1.0',
|
|
90
|
-
id: '5CUFVHAA7XZFZDRXO5J2Q26O6O4KB6DHSOB54P5LO3S57S2JF5NA',
|
|
91
|
-
intraRoundOffset: 12,
|
|
92
|
-
lastValid: 27082664,
|
|
93
|
-
receiverRewards: 0,
|
|
94
|
-
roundTime: 1674020229,
|
|
95
|
-
sender: '7JMGBIDKQRR4MC3DNC73QU4QUNNN43VNY5RYPN2FRWEG6NXAHQMCPD4BIQ',
|
|
96
|
-
senderRewards: 0,
|
|
97
|
-
signature: {
|
|
98
|
-
sig: 'rawhKc26WQe98vKweozDOJmH32c60fI83ddi5kwXg2BYu8EJCh0V3dlzRkOcY/4C3Gh7Bkzi12Yte9EejE1QBw==',
|
|
99
|
-
},
|
|
100
|
-
txType: 'acfg',
|
|
101
|
-
};
|
|
102
|
-
expect((0, algorand_1.filterTransaction)(tx, {
|
|
103
|
-
txType: 'acfg',
|
|
104
|
-
sender: '7JMGBIDKQRR4MC3DNC73QU4QUNNN43VNY5RYPN2FRWEG6NXAHQMCPD4BIQ',
|
|
105
|
-
})).toBe(true);
|
|
106
|
-
});
|
|
107
|
-
// This is failing since switching from algo explorer api. This is due to a node configuration limit
|
|
108
|
-
it('paginate large blocks', async () => {
|
|
109
|
-
[app, apiService] = await (0, exports.prepareApiService)(testnetEndpoint, testnetChainId);
|
|
110
|
-
const failingBlock = 27739202; // testnet
|
|
111
|
-
const api = apiService.api;
|
|
112
|
-
const paginateSpy = jest.spyOn(api, 'paginatedTransactions');
|
|
113
|
-
const result = await api.getBlockByHeight(failingBlock);
|
|
114
|
-
expect(paginateSpy).toHaveBeenCalledTimes(3);
|
|
115
|
-
expect(result.transactions.length).toEqual(13916);
|
|
116
|
-
});
|
|
117
|
-
it('can stringify blocks and transactions with circular references', async () => {
|
|
118
|
-
[app, apiService] = await (0, exports.prepareApiService)();
|
|
119
|
-
const block = await apiService.api.getBlockByHeight(30478896);
|
|
120
|
-
// The circular ref
|
|
121
|
-
expect(block.transactions[13].block).toBeDefined();
|
|
122
|
-
// We can stringify the objects
|
|
123
|
-
expect(() => JSON.stringify(block)).not.toThrow();
|
|
124
|
-
expect(() => JSON.stringify(block.transactions[13])).not.toThrow();
|
|
125
|
-
expect(JSON.parse(JSON.stringify(block)).round).toEqual(block.round);
|
|
126
|
-
});
|
|
127
|
-
it('can get the grouped transactions within a block', async () => {
|
|
128
|
-
[app, apiService] = await (0, exports.prepareApiService)();
|
|
129
|
-
const block = await apiService.api.getBlockByHeight(30478896);
|
|
130
|
-
const groupTx = block.getTransactionsByGroup(block.transactions[13].group);
|
|
131
|
-
expect(groupTx.length).toEqual(3);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
//# sourceMappingURL=algorand.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"algorand.spec.js","sourceRoot":"","sources":["../../src/algorand/algorand.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAGnC,yDAA0E;AAC1E,6CAAuC;AACvC,gDAK0B;AAC1B,qCAAwC;AACxC,0CAAoE;AAGpE,MAAM,eAAe,GAAG,qCAAqC,CAAC;AAC9D,MAAM,eAAe,GAAG,oCAAoC,CAAC;AAE7D,MAAM,cAAc,GAAG,8CAA8C,CAAC;AACtE,MAAM,cAAc,GAAG,8CAA8C,CAAC;AAEtE,SAAS,mBAAmB,CAAC,QAAgB,EAAE,OAAO;IACpD,OAAO;QACL,OAAO,EAAE;YACP,OAAO;YACP,QAAQ,EAAE,CAAC,QAAQ,CAAC;YACpB,UAAU,EAAE,8DAA8D;SAC3E;QACD,WAAW,EAAE,EAAE;QACf,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,IAAI,uBAAa,CAAC,EAAE,CAAC;QAC7B,SAAS,EAAE,EAAE;KACP,CAAC;AACX,CAAC;AAED,0CAA0C;AACnC,MAAM,iBAAiB,GAAG,KAAK,EACpC,WAAmB,eAAe,EAClC,UAAkB,cAAc,EACiB,EAAE;IACnD,MAAM,MAAM,GAAG,MAAM,cAAI,CAAC,mBAAmB,CAAC;QAC5C,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,kB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AAY,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QAE3E,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { INestApplication } from '@nestjs/common';\nimport { EventEmitter2, EventEmitterModule } from '@nestjs/event-emitter';\nimport { Test } from '@nestjs/testing';\nimport {\n ApiService,\n ConnectionPoolService,\n ConnectionPoolStateManager,\n NodeConfig,\n} from '@subql/node-core';\nimport { GraphQLSchema } from 'graphql';\nimport { AlgorandApiService, filterTransaction } from '../algorand';\nimport { SubqueryProject } from '../configure/SubqueryProject';\n\nconst mainnetEndpoint = 'https://mainnet-idx.algonode.cloud/';\nconst testnetEndpoint = 'https://testnet-idx.algonode.cloud';\n\nconst mainnetChainId = 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=';\nconst testnetChainId = 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=';\n\nfunction testSubqueryProject(endpoint: string, chainId): SubqueryProject {\n return {\n network: {\n chainId,\n endpoint: [endpoint],\n dictionary: `https://api.subquery.network/sq/subquery/Algorand-Dictionary`,\n },\n dataSources: [],\n id: 'test',\n root: './',\n schema: new GraphQLSchema({}),\n templates: [],\n } as any;\n}\n\n// eslint-disable-next-line jest/no-export\nexport const prepareApiService = async (\n endpoint: string = mainnetEndpoint,\n chainId: string = mainnetChainId,\n): Promise<[INestApplication, AlgorandApiService]> => {\n const module = await Test.createTestingModule({\n providers: [\n {\n provide: 'ISubqueryProject',\n useFactory: () => testSubqueryProject(endpoint, chainId),\n },\n NodeConfig,\n ConnectionPoolStateManager,\n ConnectionPoolService,\n {\n provide: AlgorandApiService,\n useFactory: AlgorandApiService.init,\n inject: ['ISubqueryProject', ConnectionPoolService, EventEmitter2],\n },\n ],\n imports: [EventEmitterModule.forRoot()],\n }).compile();\n\n const app = module.createNestApplication();\n await app.init();\n const apiService = app.get(AlgorandApiService);\n\n return [app, apiService];\n};\n\njest.setTimeout(90000);\ndescribe('Algorand RPC', () => {\n let app: INestApplication;\n let apiService: ApiService;\n\n afterEach(() => {\n return app?.close();\n });\n\n it('Can filter acfg with sender', () => {\n const tx = {\n assetConfigTransaction: {\n assetId: 0,\n params: {\n clawback:\n '7JMGBIDKQRR4MC3DNC73QU4QUNNN43VNY5RYPN2FRWEG6NXAHQMCPD4BIQ',\n creator: '7JMGBIDKQRR4MC3DNC73QU4QUNNN43VNY5RYPN2FRWEG6NXAHQMCPD4BIQ',\n decimals: 0,\n defaultFrozen: false,\n freeze: '7JMGBIDKQRR4MC3DNC73QU4QUNNN43VNY5RYPN2FRWEG6NXAHQMCPD4BIQ',\n manager: '7JMGBIDKQRR4MC3DNC73QU4QUNNN43VNY5RYPN2FRWEG6NXAHQMCPD4BIQ',\n name: 'flowTest.algo',\n nameB64: 'Zmxvd1Rlc3QuYWxnbw==',\n reserve: '7JMGBIDKQRR4MC3DNC73QU4QUNNN43VNY5RYPN2FRWEG6NXAHQMCPD4BIQ',\n total: 1,\n unitName: 'xAns',\n unitNameB64: 'eEFucw==',\n url: 'https://xgov.app',\n urlB64: 'aHR0cHM6Ly94Z292LmFwcA==',\n },\n },\n closeRewards: 0,\n closingAmount: 0,\n confirmedRound: 27081666,\n createdAssetIndex: 154583116,\n fee: 1000,\n firstValid: 27081664,\n genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',\n genesisId: 'testnet-v1.0',\n id: '5CUFVHAA7XZFZDRXO5J2Q26O6O4KB6DHSOB54P5LO3S57S2JF5NA',\n intraRoundOffset: 12,\n lastValid: 27082664,\n receiverRewards: 0,\n roundTime: 1674020229,\n sender: '7JMGBIDKQRR4MC3DNC73QU4QUNNN43VNY5RYPN2FRWEG6NXAHQMCPD4BIQ',\n senderRewards: 0,\n signature: {\n sig: 'rawhKc26WQe98vKweozDOJmH32c60fI83ddi5kwXg2BYu8EJCh0V3dlzRkOcY/4C3Gh7Bkzi12Yte9EejE1QBw==',\n },\n txType: 'acfg',\n };\n\n expect(\n filterTransaction(tx as any, {\n txType: 'acfg',\n sender: '7JMGBIDKQRR4MC3DNC73QU4QUNNN43VNY5RYPN2FRWEG6NXAHQMCPD4BIQ',\n }),\n ).toBe(true);\n });\n\n // This is failing since switching from algo explorer api. This is due to a node configuration limit\n it('paginate large blocks', async () => {\n [app, apiService] = await prepareApiService(\n testnetEndpoint,\n testnetChainId,\n );\n const failingBlock = 27739202; // testnet\n const api = apiService.api;\n\n const paginateSpy = jest.spyOn(api, 'paginatedTransactions');\n const result = await api.getBlockByHeight(failingBlock);\n expect(paginateSpy).toHaveBeenCalledTimes(3);\n expect(result.transactions.length).toEqual(13916);\n });\n\n it('can stringify blocks and transactions with circular references', async () => {\n [app, apiService] = await prepareApiService();\n\n const block = await apiService.api.getBlockByHeight(30478896);\n\n // The circular ref\n expect(block.transactions[13].block).toBeDefined();\n\n // We can stringify the objects\n expect(() => JSON.stringify(block)).not.toThrow();\n expect(() => JSON.stringify(block.transactions[13])).not.toThrow();\n\n expect(JSON.parse(JSON.stringify(block)).round).toEqual(block.round);\n });\n\n it('can get the grouped transactions within a block', async () => {\n [app, apiService] = await prepareApiService();\n\n const block = await apiService.api.getBlockByHeight(30478896);\n\n const groupTx = block.getTransactionsByGroup(block.transactions[13].group);\n\n expect(groupTx.length).toEqual(3);\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
3
|
-
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
const algorand_spec_1 = require("./algorand.spec");
|
|
6
|
-
const utils_algorand_1 = require("./utils.algorand");
|
|
7
|
-
describe('Algorand Filters', () => {
|
|
8
|
-
describe('Transaction Filters', () => {
|
|
9
|
-
let app;
|
|
10
|
-
let api;
|
|
11
|
-
let block;
|
|
12
|
-
beforeAll(async () => {
|
|
13
|
-
[app, api] = await (0, algorand_spec_1.prepareApiService)();
|
|
14
|
-
block = await api.api.getBlockByHeight(30478896);
|
|
15
|
-
});
|
|
16
|
-
afterAll(async () => {
|
|
17
|
-
await app?.close();
|
|
18
|
-
});
|
|
19
|
-
it('returns true with no filter', () => {
|
|
20
|
-
expect((0, utils_algorand_1.filterTransaction)(block.transactions[13])).toBeTruthy();
|
|
21
|
-
});
|
|
22
|
-
it('can fillter by sender', () => {
|
|
23
|
-
expect((0, utils_algorand_1.filterTransaction)(block.transactions[13], {
|
|
24
|
-
sender: '5GMADASEGJ324HR4GI2XZ2BNSN77ND45LLF4F4XDTAYX3YM6TX5YEU4FEA',
|
|
25
|
-
})).toBeTruthy();
|
|
26
|
-
expect((0, utils_algorand_1.filterTransaction)(block.transactions[13], {
|
|
27
|
-
sender: 'WRONG_ADDRESSS',
|
|
28
|
-
})).toBeFalsy();
|
|
29
|
-
});
|
|
30
|
-
it('can fillter by receiver', () => {
|
|
31
|
-
expect((0, utils_algorand_1.filterTransaction)(block.transactions[18], {
|
|
32
|
-
receiver: 'V6CK3HRC4JBRBDIBB4JWOBMYNUYIP7SYHRPVHH5ZMJQME337C57IBIZVFI',
|
|
33
|
-
})).toBeTruthy();
|
|
34
|
-
expect((0, utils_algorand_1.filterTransaction)(block.transactions[18], {
|
|
35
|
-
receiver: 'WRONG_ADDRESSS',
|
|
36
|
-
})).toBeFalsy();
|
|
37
|
-
});
|
|
38
|
-
it('can fillter by application id', () => {
|
|
39
|
-
expect((0, utils_algorand_1.filterTransaction)(block.transactions[13], {
|
|
40
|
-
applicationId: 971368268,
|
|
41
|
-
})).toBeTruthy();
|
|
42
|
-
expect((0, utils_algorand_1.filterTransaction)(block.transactions[13], { applicationId: 0 })).toBeFalsy();
|
|
43
|
-
});
|
|
44
|
-
it('can fillter by application args', () => {
|
|
45
|
-
// Filter single argument (function signature)
|
|
46
|
-
expect((0, utils_algorand_1.filterTransaction)(block.transactions[13], {
|
|
47
|
-
applicationArgs: ['udVC+w=='],
|
|
48
|
-
})).toBeTruthy();
|
|
49
|
-
// Filter all arguments
|
|
50
|
-
expect((0, utils_algorand_1.filterTransaction)(block.transactions[13], {
|
|
51
|
-
applicationArgs: ['udVC+w==', 'AQ==', 'AA==', 'AQ==', 'AQ=='],
|
|
52
|
-
})).toBeTruthy();
|
|
53
|
-
// Filter specific argument
|
|
54
|
-
expect((0, utils_algorand_1.filterTransaction)(block.transactions[13], {
|
|
55
|
-
applicationArgs: ['udVC+w==', null, null, null, 'AQ=='],
|
|
56
|
-
})).toBeTruthy();
|
|
57
|
-
});
|
|
58
|
-
it('should not filter undefined options', () => {
|
|
59
|
-
expect((0, utils_algorand_1.filterTransaction)(block.transactions[4], {
|
|
60
|
-
sender: 'ZW3ISEHZUHPO7OZGMKLKIIMKVICOUDRCERI454I3DB2BH52HGLSO67W754',
|
|
61
|
-
receiver: undefined,
|
|
62
|
-
})).toBeTruthy();
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
//# sourceMappingURL=utils.algorand.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.algorand.spec.js","sourceRoot":"","sources":["../../src/algorand/utils.algorand.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAInC,mDAAoD;AAEpD,qDAAqD;AAErD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;QACnC,IAAI,GAAqB,CAAC;QAC1B,IAAI,GAAuB,CAAC;QAC5B,IAAI,KAAoB,CAAC;QAEzB,SAAS,CAAC,KAAK,IAAI,EAAE;YACnB,CAAC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jB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { INestApplication } from '@nestjs/common';\nimport { AlgorandBlock } from '@subql/types-algorand';\nimport { prepareApiService } from './algorand.spec';\nimport { AlgorandApiService } from './api.service.algorand';\nimport { filterTransaction } from './utils.algorand';\n\ndescribe('Algorand Filters', () => {\n describe('Transaction Filters', () => {\n let app: INestApplication;\n let api: AlgorandApiService;\n let block: AlgorandBlock;\n\n beforeAll(async () => {\n [app, api] = await prepareApiService();\n\n block = await api.api.getBlockByHeight(30478896);\n });\n\n afterAll(async () => {\n await app?.close();\n });\n\n it('returns true with no filter', () => {\n expect(filterTransaction(block.transactions![13])).toBeTruthy();\n });\n\n it('can fillter by sender', () => {\n expect(\n filterTransaction(block.transactions![13], {\n sender: '5GMADASEGJ324HR4GI2XZ2BNSN77ND45LLF4F4XDTAYX3YM6TX5YEU4FEA',\n }),\n ).toBeTruthy();\n expect(\n filterTransaction(block.transactions![13], {\n sender: 'WRONG_ADDRESSS',\n }),\n ).toBeFalsy();\n });\n\n it('can fillter by receiver', () => {\n expect(\n filterTransaction(block.transactions![18], {\n receiver:\n 'V6CK3HRC4JBRBDIBB4JWOBMYNUYIP7SYHRPVHH5ZMJQME337C57IBIZVFI',\n }),\n ).toBeTruthy();\n expect(\n filterTransaction(block.transactions![18], {\n receiver: 'WRONG_ADDRESSS',\n }),\n ).toBeFalsy();\n });\n\n it('can fillter by application id', () => {\n expect(\n filterTransaction(block.transactions![13], {\n applicationId: 971368268,\n }),\n ).toBeTruthy();\n expect(\n filterTransaction(block.transactions![13], { applicationId: 0 }),\n ).toBeFalsy();\n });\n\n it('can fillter by application args', () => {\n // Filter single argument (function signature)\n expect(\n filterTransaction(block.transactions![13], {\n applicationArgs: ['udVC+w=='],\n }),\n ).toBeTruthy();\n // Filter all arguments\n expect(\n filterTransaction(block.transactions![13], {\n applicationArgs: ['udVC+w==', 'AQ==', 'AA==', 'AQ==', 'AQ=='],\n }),\n ).toBeTruthy();\n // Filter specific argument\n expect(\n filterTransaction(block.transactions![13], {\n applicationArgs: ['udVC+w==', null, null, null, 'AQ=='] as any,\n }),\n ).toBeTruthy();\n });\n\n it('should not filter undefined options', () => {\n expect(\n filterTransaction(block.transactions![4], {\n sender: 'ZW3ISEHZUHPO7OZGMKLKIIMKVICOUDRCERI454I3DB2BH52HGLSO67W754',\n receiver: undefined,\n }),\n ).toBeTruthy();\n });\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
3
|
-
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
6
|
-
const testing_1 = require("@nestjs/testing");
|
|
7
|
-
const node_core_1 = require("@subql/node-core");
|
|
8
|
-
const graphql_1 = require("graphql");
|
|
9
|
-
const algorand_1 = require("../algorand");
|
|
10
|
-
const ENDPOINT = 'https://mainnet-idx.algonode.cloud/';
|
|
11
|
-
function testSubqueryProject(endpoint) {
|
|
12
|
-
return {
|
|
13
|
-
network: {
|
|
14
|
-
endpoint: [endpoint],
|
|
15
|
-
dictionary: `https://api.subquery.network/sq/subquery/Algorand-Dictionary`,
|
|
16
|
-
chainId: 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=',
|
|
17
|
-
},
|
|
18
|
-
dataSources: [],
|
|
19
|
-
id: 'test',
|
|
20
|
-
root: './',
|
|
21
|
-
schema: new graphql_1.GraphQLSchema({}),
|
|
22
|
-
templates: [],
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
jest.setTimeout(90000);
|
|
26
|
-
describe('ApiService', () => {
|
|
27
|
-
let app;
|
|
28
|
-
afterEach(() => {
|
|
29
|
-
return app?.close();
|
|
30
|
-
});
|
|
31
|
-
const prepareApiService = async (endpoint = ENDPOINT) => {
|
|
32
|
-
const module = await testing_1.Test.createTestingModule({
|
|
33
|
-
providers: [
|
|
34
|
-
{
|
|
35
|
-
provide: 'ISubqueryProject',
|
|
36
|
-
useFactory: () => testSubqueryProject(endpoint),
|
|
37
|
-
},
|
|
38
|
-
node_core_1.ConnectionPoolStateManager,
|
|
39
|
-
node_core_1.ConnectionPoolService,
|
|
40
|
-
node_core_1.NodeConfig,
|
|
41
|
-
{
|
|
42
|
-
provide: algorand_1.AlgorandApiService,
|
|
43
|
-
useFactory: algorand_1.AlgorandApiService.init,
|
|
44
|
-
inject: ['ISubqueryProject', node_core_1.ConnectionPoolService, event_emitter_1.EventEmitter2],
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
imports: [event_emitter_1.EventEmitterModule.forRoot()],
|
|
48
|
-
}).compile();
|
|
49
|
-
app = module.createNestApplication();
|
|
50
|
-
await app.init();
|
|
51
|
-
const apiService = app.get(algorand_1.AlgorandApiService);
|
|
52
|
-
return apiService;
|
|
53
|
-
};
|
|
54
|
-
it('can fetch block with hash', async () => {
|
|
55
|
-
const apiService = await prepareApiService();
|
|
56
|
-
const block = (await apiService.api.fetchBlocks([50000]))[0];
|
|
57
|
-
expect(block.block.hash).toEqual('Gss169f22yVUBJzbNT9qXtQukjh0tgecvapaQY5NIRg=');
|
|
58
|
-
});
|
|
59
|
-
it('waits on pending block to fetch hash', async () => {
|
|
60
|
-
const apiService = await prepareApiService();
|
|
61
|
-
const api = apiService.api;
|
|
62
|
-
const checkHealth = await api.api.makeHealthCheck().do();
|
|
63
|
-
const currentRound = checkHealth.round;
|
|
64
|
-
const fetchLatestBlock = async () => (await apiService.api.fetchBlocks([currentRound]))[0];
|
|
65
|
-
expect(fetchLatestBlock).not.toThrow();
|
|
66
|
-
const block = await fetchLatestBlock();
|
|
67
|
-
expect(block.block.hash).toBeDefined();
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
//# sourceMappingURL=api.service.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.service.spec.js","sourceRoot":"","sources":["../../src/indexer/api.service.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAGnC,yDAA0E;AAC1E,6CAAuC;AACvC,gDAI0B;AAC1B,qCAAwC;AACxC,0CAAiD;AAGjD,MAAM,QAAQ,GAAG,qCAAqC,CAAC;AAEvD,SAAS,mBAAmB,CAAC,QAAgB;IAC3C,OAAO;QACL,OAAO,EAAE;YACP,QAAQ,EAAE,CAAC,QAAQ,CAAC;YACpB,UAAU,EAAE,8DAA8D;YAC1E,OAAO,EAAE,8CAA8C;SACxD;QACD,WAAW,EAAE,EAAE;QACf,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,IAAI,uBAAa,CAAC,EAAE,CAAC;QAC7B,SAAS,EAAE,EAAE;KACP,CAAC;AACX,CAAC;AAED,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AACvB,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,IAAI,GAAqB,CAAC;IAE1B,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,GAAG,EAAE,KAAK,EAAE,CAAC;IACtB,CAAC,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,KAAK,EAC7B,WAAmB,QAAQ,EACE,EAAE;QAC/B,MAAM,MAAM,GAAG,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC5C,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,kBAAkB;oBAC3B,UAAU,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,QAAQ,CAAC;iBAChD;gBACD,sCAA0B;gBAC1B,iCAAqB;gBACrB,sBAAU;gBACV;oBACE,OAAO,EAAE,6BAAkB;oBAC3B,UA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AAC,GAAG,CAAC,OAAO,EAAE,CAAC;QAEvC,MAAM,KAAK,GAAG,MAAM,gBAAgB,EAAE,CAAC;QACvC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { INestApplication } from '@nestjs/common';\nimport { EventEmitter2, EventEmitterModule } from '@nestjs/event-emitter';\nimport { Test } from '@nestjs/testing';\nimport {\n ConnectionPoolService,\n ConnectionPoolStateManager,\n NodeConfig,\n} from '@subql/node-core';\nimport { GraphQLSchema } from 'graphql';\nimport { AlgorandApiService } from '../algorand';\nimport { SubqueryProject } from '../configure/SubqueryProject';\n\nconst ENDPOINT = 'https://mainnet-idx.algonode.cloud/';\n\nfunction testSubqueryProject(endpoint: string): SubqueryProject {\n return {\n network: {\n endpoint: [endpoint],\n dictionary: `https://api.subquery.network/sq/subquery/Algorand-Dictionary`,\n chainId: 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=',\n },\n dataSources: [],\n id: 'test',\n root: './',\n schema: new GraphQLSchema({}),\n templates: [],\n } as any;\n}\n\njest.setTimeout(90000);\ndescribe('ApiService', () => {\n let app: INestApplication;\n\n afterEach(() => {\n return app?.close();\n });\n\n const prepareApiService = async (\n endpoint: string = ENDPOINT,\n ): Promise<AlgorandApiService> => {\n const module = await Test.createTestingModule({\n providers: [\n {\n provide: 'ISubqueryProject',\n useFactory: () => testSubqueryProject(endpoint),\n },\n ConnectionPoolStateManager,\n ConnectionPoolService,\n NodeConfig,\n {\n provide: AlgorandApiService,\n useFactory: AlgorandApiService.init,\n inject: ['ISubqueryProject', ConnectionPoolService, EventEmitter2],\n },\n ],\n imports: [EventEmitterModule.forRoot()],\n }).compile();\n\n app = module.createNestApplication();\n await app.init();\n const apiService = app.get(AlgorandApiService);\n\n return apiService;\n };\n\n it('can fetch block with hash', async () => {\n const apiService = await prepareApiService();\n\n const block = (await apiService.api.fetchBlocks([50000]))[0];\n\n expect(block.block.hash).toEqual(\n 'Gss169f22yVUBJzbNT9qXtQukjh0tgecvapaQY5NIRg=',\n );\n });\n\n it('waits on pending block to fetch hash', async () => {\n const apiService = await prepareApiService();\n const api = apiService.api;\n\n const checkHealth = await api.api.makeHealthCheck().do();\n const currentRound = checkHealth.round;\n\n const fetchLatestBlock = async () =>\n (await apiService.api.fetchBlocks([currentRound]))[0];\n\n expect(fetchLatestBlock).not.toThrow();\n\n const block = await fetchLatestBlock();\n expect(block.block.hash).toBeDefined();\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors
|
|
3
|
-
// SPDX-License-Identifier: GPL-3.0
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
6
|
-
const common_1 = require("@subql/common");
|
|
7
|
-
const node_core_1 = require("@subql/node-core");
|
|
8
|
-
const types_algorand_1 = require("@subql/types-algorand");
|
|
9
|
-
const algorandDictionaryV1_1 = require("./algorandDictionaryV1");
|
|
10
|
-
const mockDs = [
|
|
11
|
-
{
|
|
12
|
-
startBlock: 8712119,
|
|
13
|
-
kind: types_algorand_1.AlgorandDataSourceKind.Runtime,
|
|
14
|
-
mapping: {
|
|
15
|
-
handlers: [
|
|
16
|
-
{
|
|
17
|
-
filter: {
|
|
18
|
-
txType: 'axfer',
|
|
19
|
-
sender: 'ZW3ISEHZUHPO7OZGMKLKIIMKVICOUDRCERI454I3DB2BH52HGLSO67W754',
|
|
20
|
-
assetId: 27165954,
|
|
21
|
-
},
|
|
22
|
-
kind: 'algorand/TransactionHandler',
|
|
23
|
-
handler: 'handleTransaction',
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
file: './dist/index.js',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
];
|
|
30
|
-
const nodeConfig = {
|
|
31
|
-
dictionaryTimeout: 10000,
|
|
32
|
-
dictionaryRegistry: 'https://github.com/subquery/templates/raw/main/dist/dictionary.json',
|
|
33
|
-
};
|
|
34
|
-
const project = {
|
|
35
|
-
network: {
|
|
36
|
-
chainId: 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=',
|
|
37
|
-
},
|
|
38
|
-
dataSources: mockDs,
|
|
39
|
-
};
|
|
40
|
-
class TestDictionaryService extends node_core_1.DictionaryService {
|
|
41
|
-
async initDictionaries() {
|
|
42
|
-
return Promise.resolve(undefined);
|
|
43
|
-
}
|
|
44
|
-
async getRegistryDictionaries(chainId) {
|
|
45
|
-
return this.resolveDictionary(common_1.NETWORK_FAMILY.algorand, chainId, this.nodeConfig.dictionaryRegistry);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
describe('dictionary v1', () => {
|
|
49
|
-
let dictionary;
|
|
50
|
-
beforeEach(async () => {
|
|
51
|
-
const testDictionaryService = new TestDictionaryService(project.network.chainId, nodeConfig, new event_emitter_1.EventEmitter2());
|
|
52
|
-
const dictionaryEndpoints = await testDictionaryService.getRegistryDictionaries(project.network.chainId);
|
|
53
|
-
dictionary = await algorandDictionaryV1_1.AlgorandDictionaryV1.create({
|
|
54
|
-
network: {
|
|
55
|
-
chainId: 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=',
|
|
56
|
-
dictionary: dictionaryEndpoints[1],
|
|
57
|
-
},
|
|
58
|
-
dataSources: mockDs,
|
|
59
|
-
}, { dictionaryTimeout: 10000 }, jest.fn(), dictionaryEndpoints[1]);
|
|
60
|
-
});
|
|
61
|
-
it('successfully validates metatada', () => {
|
|
62
|
-
// start height from metadata
|
|
63
|
-
expect(dictionary.startHeight).toBe(1);
|
|
64
|
-
// further validation
|
|
65
|
-
expect(dictionary.dictionaryValidation({
|
|
66
|
-
lastProcessedHeight: 10000,
|
|
67
|
-
targetHeight: 10000,
|
|
68
|
-
chain: 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=',
|
|
69
|
-
genesisHash: 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=',
|
|
70
|
-
startHeight: 1,
|
|
71
|
-
}, 1)).toBeTruthy();
|
|
72
|
-
});
|
|
73
|
-
it('build correct dictionary entries and remove undefined fields in filter', () => {
|
|
74
|
-
expect(dictionary.buildDictionaryQueryEntries(mockDs)).toEqual([
|
|
75
|
-
{
|
|
76
|
-
conditions: [
|
|
77
|
-
{
|
|
78
|
-
field: 'txType',
|
|
79
|
-
matcher: 'equalTo',
|
|
80
|
-
value: 'axfer',
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
field: 'sender',
|
|
84
|
-
matcher: 'equalTo',
|
|
85
|
-
value: 'ZW3ISEHZUHPO7OZGMKLKIIMKVICOUDRCERI454I3DB2BH52HGLSO67W754',
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
field: 'assetId',
|
|
89
|
-
matcher: 'equalTo',
|
|
90
|
-
value: 27165954,
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
entity: 'transactions',
|
|
94
|
-
},
|
|
95
|
-
]);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
//# sourceMappingURL=algorandDictionaryV1.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"algorandDictionaryV1.spec.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v1/algorandDictionaryV1.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;AAEnC,yDAAsD;AACtD,0CAA+C;AAC/C,gDAAiE;AACjE,0DAG+B;AAE/B,iEAA8D;AAE9D,MAAM,MAAM,GAAG;IACb;QACE,UAAU,E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E,8CAA8C;gBACvD,UAAU,EAAE,mBAAmB,CAAC,CAAC,CAAC;aACnC;YACD,WAAW,EAAE,MAAM;SACb,EACR,EAAE,iBAAiB,EAAE,KAAK,EAAgB,EAC1C,IAAI,CAAC,EAAE,EAAE,EACT,mBAAmB,CAAC,CAAC,CAAC,CACvB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,6BAA6B;QAC7B,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACvC,qBAAqB;QACrB,MAAM,CACH,UAAkB,CAAC,oBAAoB,CACtC;YACE,mBAAmB,EAAE,KAAK;YAC1B,YAAY,EAAE,KAAK;YACnB,KAAK,EAAE,8CAA8C;YACrD,WAAW,EAAE,8CAA8C;YAC3D,WAAW,EAAE,CAAC;SACH,EACb,CAAC,CACF,CACF,CAAC,UAAU,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wEAAwE,EAAE,GAAG,EAAE;QAChF,MAAM,CAAC,UAAU,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;YAC7D;gBACE,UAAU,EAAE;oBACV;wBACE,KAAK,EAAE,QAAQ;wBACf,OAAO,EAAE,SAAS;wBAClB,KAAK,EAAE,OAAO;qBACf;oBACD;wBACE,KAAK,EAAE,QAAQ;wBACf,OAAO,EAAE,SAAS;wBAClB,KAAK,EAAE,4DAA4D;qBACpE;oBACD;wBACE,KAAK,EAAE,SAAS;wBAChB,OAAO,EAAE,SAAS;wBAClB,KAAK,EAAE,QAAQ;qBAChB;iBACF;gBACD,MAAM,EAAE,cAAc;aACvB;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2025 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { NETWORK_FAMILY } from '@subql/common';\nimport { DictionaryService, NodeConfig } from '@subql/node-core';\nimport {\n AlgorandDataSource,\n AlgorandDataSourceKind,\n} from '@subql/types-algorand';\nimport { MetaData } from '@subql/utils';\nimport { AlgorandDictionaryV1 } from './algorandDictionaryV1';\n\nconst mockDs = [\n {\n startBlock: 8712119,\n kind: AlgorandDataSourceKind.Runtime,\n mapping: {\n handlers: [\n {\n filter: {\n txType: 'axfer',\n sender:\n 'ZW3ISEHZUHPO7OZGMKLKIIMKVICOUDRCERI454I3DB2BH52HGLSO67W754',\n assetId: 27165954,\n },\n kind: 'algorand/TransactionHandler',\n handler: 'handleTransaction',\n },\n ],\n file: './dist/index.js',\n },\n },\n] as AlgorandDataSource[];\n\nconst nodeConfig = {\n dictionaryTimeout: 10000,\n dictionaryRegistry:\n 'https://github.com/subquery/templates/raw/main/dist/dictionary.json',\n} as NodeConfig;\nconst project = {\n network: {\n chainId: 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=',\n },\n dataSources: mockDs,\n} as any;\n\nclass TestDictionaryService extends DictionaryService<any, any> {\n async initDictionaries(): Promise<void> {\n return Promise.resolve(undefined);\n }\n async getRegistryDictionaries(chainId: string): Promise<string[]> {\n return this.resolveDictionary(\n NETWORK_FAMILY.algorand,\n chainId,\n this.nodeConfig.dictionaryRegistry,\n );\n }\n}\ndescribe('dictionary v1', () => {\n let dictionary: AlgorandDictionaryV1;\n beforeEach(async () => {\n const testDictionaryService = new TestDictionaryService(\n project.network.chainId,\n nodeConfig,\n new EventEmitter2(),\n );\n const dictionaryEndpoints =\n await testDictionaryService.getRegistryDictionaries(\n project.network.chainId,\n );\n dictionary = await AlgorandDictionaryV1.create(\n {\n network: {\n chainId: 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=',\n dictionary: dictionaryEndpoints[1],\n },\n dataSources: mockDs,\n } as any,\n { dictionaryTimeout: 10000 } as NodeConfig,\n jest.fn(),\n dictionaryEndpoints[1], // use endpoint from network\n );\n });\n\n it('successfully validates metatada', () => {\n // start height from metadata\n expect(dictionary.startHeight).toBe(1);\n // further validation\n expect(\n (dictionary as any).dictionaryValidation(\n {\n lastProcessedHeight: 10000,\n targetHeight: 10000,\n chain: 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=',\n genesisHash: 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=',\n startHeight: 1,\n } as MetaData,\n 1,\n ),\n ).toBeTruthy();\n });\n\n it('build correct dictionary entries and remove undefined fields in filter', () => {\n expect(dictionary.buildDictionaryQueryEntries(mockDs)).toEqual([\n {\n conditions: [\n {\n field: 'txType',\n matcher: 'equalTo',\n value: 'axfer',\n },\n {\n field: 'sender',\n matcher: 'equalTo',\n value: 'ZW3ISEHZUHPO7OZGMKLKIIMKVICOUDRCERI454I3DB2BH52HGLSO67W754',\n },\n {\n field: 'assetId',\n matcher: 'equalTo',\n value: 27165954,\n },\n ],\n entity: 'transactions',\n },\n ]);\n });\n});\n"]}
|