@sentio/sdk 1.16.4 → 1.17.0
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/lib/aptos-processor.d.ts +21 -0
- package/lib/aptos-processor.js +65 -0
- package/lib/aptos-processor.js.map +1 -0
- package/lib/bind-options.d.ts +2 -0
- package/lib/bind-options.js +4 -1
- package/lib/bind-options.js.map +1 -1
- package/lib/builtin/eacaggregatorproxy/index.d.ts +2 -0
- package/lib/builtin/eacaggregatorproxy/index.js +22 -0
- package/lib/builtin/eacaggregatorproxy/index.js.map +1 -0
- package/lib/builtin/eacaggregatorproxy/test-utils.d.ts +6 -0
- package/lib/builtin/eacaggregatorproxy/test-utils.js +57 -0
- package/lib/builtin/eacaggregatorproxy/test-utils.js.map +1 -0
- package/lib/builtin/internal/EACAggregatorProxy.d.ts +460 -0
- package/lib/builtin/internal/EACAggregatorProxy.js +3 -0
- package/lib/builtin/internal/EACAggregatorProxy.js.map +1 -0
- package/lib/builtin/internal/eacaggregatorproxy_processor.d.ts +317 -0
- package/lib/builtin/internal/eacaggregatorproxy_processor.js +813 -0
- package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +1 -0
- package/lib/builtin/internal/factories/EACAggregatorProxy__factory.d.ts +46 -0
- package/lib/builtin/internal/factories/EACAggregatorProxy__factory.js +527 -0
- package/lib/builtin/internal/factories/EACAggregatorProxy__factory.js.map +1 -0
- package/lib/builtin/internal/factories/index.d.ts +1 -0
- package/lib/builtin/internal/factories/index.js +3 -1
- package/lib/builtin/internal/factories/index.js.map +1 -1
- package/lib/builtin/internal/index.d.ts +2 -0
- package/lib/builtin/internal/index.js +3 -1
- package/lib/builtin/internal/index.js.map +1 -1
- package/lib/context.d.ts +5 -0
- package/lib/context.js +15 -3
- package/lib/context.js.map +1 -1
- package/lib/gen/processor/protos/processor.d.ts +2 -0
- package/lib/gen/processor/protos/processor.js +19 -0
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/meter.js +17 -0
- package/lib/meter.js.map +1 -1
- package/lib/processor-state.d.ts +2 -0
- package/lib/processor-state.js +1 -0
- package/lib/processor-state.js.map +1 -1
- package/lib/service.js +47 -0
- package/lib/service.js.map +1 -1
- package/lib/solana/builtin/spl-token-processor.d.ts +16 -1
- package/lib/solana/builtin/spl-token-processor.js +120 -0
- package/lib/solana/builtin/spl-token-processor.js.map +1 -1
- package/lib/solana/builtin/types.d.ts +97 -0
- package/lib/solana/builtin/types.js.map +1 -1
- package/lib/test/{mirrorworld.d.ts → aptos.test.d.ts} +0 -0
- package/lib/test/aptos.test.js +142 -0
- package/lib/test/aptos.test.js.map +1 -0
- package/lib/test/erc20.js.map +1 -1
- package/lib/test/erc20.test.js.map +1 -1
- package/lib/test/solana.test.js +1 -17
- package/lib/test/solana.test.js.map +1 -1
- package/lib/test/souffl3.d.ts +1 -0
- package/lib/test/souffl3.js +24 -0
- package/lib/test/souffl3.js.map +1 -0
- package/lib/test/test-provider.d.ts +1 -1
- package/lib/test/test-provider.js +11 -5
- package/lib/test/test-provider.js.map +1 -1
- package/lib/test/types/{game_wallet.d.ts → basic_1.d.ts} +2 -21
- package/lib/test/types/basic_1.js +66 -0
- package/lib/test/types/basic_1.js.map +1 -0
- package/lib/test/types/basic_1_processor.d.ts +13 -0
- package/lib/test/types/basic_1_processor.js +41 -0
- package/lib/test/types/basic_1_processor.js.map +1 -0
- package/lib/utils/chainlink-oracles-goerli.csv +8 -0
- package/lib/utils/chainlink-oracles.csv +217 -0
- package/lib/utils/dex-price.d.ts +22 -0
- package/lib/utils/dex-price.js +114 -0
- package/lib/utils/dex-price.js.map +1 -0
- package/lib/utils/dex-price.test.d.ts +1 -0
- package/lib/utils/dex-price.test.js +22 -0
- package/lib/utils/dex-price.test.js.map +1 -0
- package/lib/utils/erc20.d.ts +1 -0
- package/lib/utils/erc20.js +7 -3
- package/lib/utils/erc20.js.map +1 -1
- package/lib/utils/index.d.ts +3 -1
- package/lib/utils/index.js +6 -1
- package/lib/utils/index.js.map +1 -1
- package/package.json +3 -3
- package/src/abis/EACAggregatorProxy.json +227 -0
- package/src/aptos-processor.ts +75 -0
- package/src/bind-options.ts +1 -0
- package/src/builtin/eacaggregatorproxy/index.ts +6 -0
- package/src/builtin/eacaggregatorproxy/test-utils.ts +89 -0
- package/src/builtin/internal/EACAggregatorProxy.ts +861 -0
- package/src/builtin/internal/eacaggregatorproxy_processor.ts +1417 -0
- package/src/builtin/internal/factories/EACAggregatorProxy__factory.ts +533 -0
- package/src/builtin/internal/factories/index.ts +1 -0
- package/src/builtin/internal/index.ts +2 -0
- package/src/context.ts +15 -2
- package/src/gen/processor/protos/processor.ts +20 -0
- package/src/index.ts +2 -1
- package/src/meter.ts +18 -2
- package/src/processor-state.ts +3 -0
- package/src/service.ts +51 -0
- package/src/solana/builtin/spl-token-processor.ts +137 -1
- package/src/solana/builtin/types.ts +11 -0
- package/src/test/abis/solana/basic_1.json +62 -0
- package/src/test/aptos.test.ts +148 -0
- package/src/test/erc20.test.ts +1 -1
- package/src/test/erc20.ts +0 -1
- package/src/test/solana.test.ts +1 -18
- package/src/test/souffl3.ts +24 -0
- package/src/test/test-provider.ts +11 -5
- package/src/test/types/basic_1.ts +62 -0
- package/src/test/types/basic_1_processor.ts +41 -0
- package/src/utils/chainlink-oracles-goerli.csv +8 -0
- package/src/utils/chainlink-oracles.csv +217 -0
- package/src/utils/dex-price.test.ts +24 -0
- package/src/utils/dex-price.ts +136 -0
- package/src/utils/erc20.ts +5 -1
- package/src/utils/index.ts +3 -1
- package/lib/test/mirrorworld.js +0 -42
- package/lib/test/mirrorworld.js.map +0 -1
- package/lib/test/types/game_wallet.js +0 -1396
- package/lib/test/types/game_wallet.js.map +0 -1
- package/lib/test/types/game_wallet_processor.d.ts +0 -107
- package/lib/test/types/game_wallet_processor.js +0 -105
- package/lib/test/types/game_wallet_processor.js.map +0 -1
- package/src/test/abis/solana/mirrorworld.json +0 -1392
- package/src/test/mirrorworld.ts +0 -40
- package/src/test/types/game_wallet.ts +0 -1392
- package/src/test/types/game_wallet_processor.ts +0 -113
package/lib/utils/erc20.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erc20.js","sourceRoot":"","sources":["../../src/utils/erc20.ts"],"names":[],"mappings":";;;AAEA,oCAA8C;AAC9C,4CAAmD;AACnD,mFAAgF;AAChF,qCAAwC;AACxC,uCAAwC;AACxC,mCAA8B;AAE9B,MAAa,SAAS;IACpB,MAAM,CAAQ;IACd,IAAI,CAAQ;IACZ,OAAO,CAAQ;CAChB;AAJD,8BAIC;AAEY,QAAA,UAAU,GAAG;IACxB,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,YAAY;CACnB,CAAA;AAED,MAAM,WAAW,GAAG,IAAI,GAAG,EAAqB,CAAA;AAEzC,KAAK,UAAU,iBAAiB,CAAC,YAAoB,EAAE,OAAO,GAAG,CAAC;IACvE,MAAM,GAAG,GAAG,OAAO,GAAG,YAAY,CAAA;IAClC,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAChC,IAAI,GAAG,EAAE;QACP,OAAO,GAAG,CAAA;KACX;IACD,MAAM,QAAQ,GAAG,IAAA,wBAAgB,EAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IACxD,MAAM,aAAa,GAAG,IAAA,4CAAqB,EAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IAElE,IAAI;QACF,kEAAkE;QAClE,IAAI,IAAI,GAAG,EAAE,CAAA;QACb,IAAI;YACF,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;SAC7B;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,GAAG,cAAK,CAAC,kBAAkB,CAAC,MAAM,aAAa,CAAC,IAAI,EAAE,CAAC,CAAA;SAC5D;QAED,IAAI,MAAM,GAAG,EAAE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AiB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IAChE,OAAO,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;AAC7C,CAAC;AAPD,0DAOC;AAED,SAAgB,SAAS,CAAC,MAAiB,EAAE,OAAe;IAC1D,MAAM,OAAO,GAAG,IAAI,gBAAU,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAC/C,OAAO,IAAA,sBAAY,EAAC,MAAM,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;AAChD,CAAC;AAHD,8BAGC","sourcesContent":["import { BigNumber } from '@ethersproject/bignumber'\n\nimport { transformEtherError } from '../error'\nimport { getERC20Contract } from '../builtin/erc20'\nimport { getERC20BytesContract } from '../builtin/internal/erc20bytes_processor'\nimport { BigDecimal } from '@sentio/sdk'\nimport { toBigDecimal } from './convert'\nimport { utils } from 'ethers'\n\nexport class TokenInfo {\n symbol: string\n name: string\n decimal: number\n}\n\nexport const NATIVE_ETH = {\n symbol: 'ETH',\n decimal: 18,\n name: 'Native ETH',\n}\n\nconst TOKEN_INFOS = new Map<string, TokenInfo>()\n\nexport async function getERC20TokenInfo(tokenAddress: string, chainId = 1): Promise<TokenInfo> {\n const key = chainId + tokenAddress\n const res = TOKEN_INFOS.get(key)\n if (res) {\n return res\n }\n const contract = getERC20Contract(tokenAddress, chainId)\n const bytesContract = getERC20BytesContract(tokenAddress, chainId)\n\n try {\n // TODO maybe not do try catch, just do raw call the parse results\n let name = ''\n try {\n name = await contract.name()\n } catch (e) {\n name = utils.parseBytes32String(await bytesContract.name())\n }\n\n let symbol = ''\n try {\n symbol = await contract.symbol()\n } catch (e) {\n symbol = utils.parseBytes32String(await bytesContract.symbol())\n }\n\n const decimal = await contract.decimals()\n const info: TokenInfo = { name, symbol, decimal }\n TOKEN_INFOS.set(key, info)\n return info\n } catch (e) {\n throw transformEtherError(e, undefined)\n }\n}\n\nexport async function getER20NormalizedAmount(\n tokenAddress: string,\n amount: BigNumber,\n chainId: number\n): Promise<BigDecimal> {\n const tokenInfo = await getERC20TokenInfo(tokenAddress, chainId)\n return scaleDown(amount, tokenInfo.decimal)\n}\n\nexport function scaleDown(amount: BigNumber, decimal: number) {\n const divider = new BigDecimal(10).pow(decimal)\n return toBigDecimal(amount).dividedBy(divider)\n}\n"]}
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { getChainName } from './chainmap';
|
|
2
2
|
export { toBigDecimal, metricValueToNumberish } from './convert';
|
|
3
|
-
export { getERC20TokenInfo, getER20NormalizedAmount, TokenInfo, NATIVE_ETH } from './erc20';
|
|
3
|
+
export { getERC20TokenInfo, getER20NormalizedAmount, scaleDown, TokenInfo, NATIVE_ETH } from './erc20';
|
|
4
|
+
export { EthereumDexPrice, GoerliDexPrice, PriceUnit } from './dex-price';
|
|
5
|
+
export type { DexPriceResult } from './dex-price';
|
package/lib/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NATIVE_ETH = exports.TokenInfo = exports.getER20NormalizedAmount = exports.getERC20TokenInfo = exports.metricValueToNumberish = exports.toBigDecimal = exports.getChainName = void 0;
|
|
3
|
+
exports.PriceUnit = exports.GoerliDexPrice = exports.EthereumDexPrice = exports.NATIVE_ETH = exports.TokenInfo = exports.scaleDown = exports.getER20NormalizedAmount = exports.getERC20TokenInfo = exports.metricValueToNumberish = exports.toBigDecimal = exports.getChainName = void 0;
|
|
4
4
|
var chainmap_1 = require("./chainmap");
|
|
5
5
|
Object.defineProperty(exports, "getChainName", { enumerable: true, get: function () { return chainmap_1.getChainName; } });
|
|
6
6
|
var convert_1 = require("./convert");
|
|
@@ -9,6 +9,11 @@ Object.defineProperty(exports, "metricValueToNumberish", { enumerable: true, get
|
|
|
9
9
|
var erc20_1 = require("./erc20");
|
|
10
10
|
Object.defineProperty(exports, "getERC20TokenInfo", { enumerable: true, get: function () { return erc20_1.getERC20TokenInfo; } });
|
|
11
11
|
Object.defineProperty(exports, "getER20NormalizedAmount", { enumerable: true, get: function () { return erc20_1.getER20NormalizedAmount; } });
|
|
12
|
+
Object.defineProperty(exports, "scaleDown", { enumerable: true, get: function () { return erc20_1.scaleDown; } });
|
|
12
13
|
Object.defineProperty(exports, "TokenInfo", { enumerable: true, get: function () { return erc20_1.TokenInfo; } });
|
|
13
14
|
Object.defineProperty(exports, "NATIVE_ETH", { enumerable: true, get: function () { return erc20_1.NATIVE_ETH; } });
|
|
15
|
+
var dex_price_1 = require("./dex-price");
|
|
16
|
+
Object.defineProperty(exports, "EthereumDexPrice", { enumerable: true, get: function () { return dex_price_1.EthereumDexPrice; } });
|
|
17
|
+
Object.defineProperty(exports, "GoerliDexPrice", { enumerable: true, get: function () { return dex_price_1.GoerliDexPrice; } });
|
|
18
|
+
Object.defineProperty(exports, "PriceUnit", { enumerable: true, get: function () { return dex_price_1.PriceUnit; } });
|
|
14
19
|
//# sourceMappingURL=index.js.map
|
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,uCAAyC;AAAhC,wGAAA,YAAY,OAAA;AACrB,qCAAgE;AAAvD,uGAAA,YAAY,OAAA;AAAE,iHAAA,sBAAsB,OAAA;AAC7C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,uCAAyC;AAAhC,wGAAA,YAAY,OAAA;AACrB,qCAAgE;AAAvD,uGAAA,YAAY,OAAA;AAAE,iHAAA,sBAAsB,OAAA;AAC7C,iCAAsG;AAA7F,0GAAA,iBAAiB,OAAA;AAAE,gHAAA,uBAAuB,OAAA;AAAE,kGAAA,SAAS,OAAA;AAAE,kGAAA,SAAS,OAAA;AAAE,mGAAA,UAAU,OAAA;AACrF,yCAAyE;AAAhE,6GAAA,gBAAgB,OAAA;AAAE,2GAAA,cAAc,OAAA;AAAE,sGAAA,SAAS,OAAA","sourcesContent":["export { getChainName } from './chainmap'\nexport { toBigDecimal, metricValueToNumberish } from './convert'\nexport { getERC20TokenInfo, getER20NormalizedAmount, scaleDown, TokenInfo, NATIVE_ETH } from './erc20'\nexport { EthereumDexPrice, GoerliDexPrice, PriceUnit } from './dex-price'\nexport type { DexPriceResult } from './dex-price'\n"]}
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentio/sdk",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.17.0",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"compile_target": "yarn tsc -b src/target-ethers-sentio/tsconfig.json",
|
|
7
|
-
"compile": "tsc -p . && cp src/cli/webpack.config.js lib/cli",
|
|
7
|
+
"compile": "tsc -p . && cp src/cli/webpack.config.js lib/cli && cp src/utils/*.csv lib/utils",
|
|
8
8
|
"build": "yarn gen && yarn compile",
|
|
9
9
|
"start_ts": "ts-node --files src/processor-runner.ts ../examples/x2y2/src/processor.ts",
|
|
10
|
-
"start_ts_solana": "ts-node --files src/processor-runner.ts ../examples/mirrorworld/src/processor.ts",
|
|
11
10
|
"start": "ts-node --files src/processor-runner.ts ../examples/x2y2/dist/lib.js",
|
|
12
11
|
"start_js": "node lib/processor.js ../examples/x2y2/dist/lib.js",
|
|
13
12
|
"ts-start": "ts-node --files src/processor-runner.ts ./src/anyswap/src/processor.ts",
|
|
@@ -31,6 +30,7 @@
|
|
|
31
30
|
"bs58": "^5.0.0",
|
|
32
31
|
"command-line-args": "^5.2.1",
|
|
33
32
|
"command-line-usage": "^6.1.3",
|
|
33
|
+
"csv-parse": "^5.3.0",
|
|
34
34
|
"ethers": "~5.7.1",
|
|
35
35
|
"form-data": "^4.0.0",
|
|
36
36
|
"fs-extra": "^10.1.0",
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"inputs": [
|
|
4
|
+
{ "internalType": "address", "name": "_aggregator", "type": "address" },
|
|
5
|
+
{ "internalType": "address", "name": "_accessController", "type": "address" }
|
|
6
|
+
],
|
|
7
|
+
"stateMutability": "nonpayable",
|
|
8
|
+
"type": "constructor"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"anonymous": false,
|
|
12
|
+
"inputs": [
|
|
13
|
+
{ "indexed": true, "internalType": "int256", "name": "current", "type": "int256" },
|
|
14
|
+
{ "indexed": true, "internalType": "uint256", "name": "roundId", "type": "uint256" },
|
|
15
|
+
{ "indexed": false, "internalType": "uint256", "name": "updatedAt", "type": "uint256" }
|
|
16
|
+
],
|
|
17
|
+
"name": "AnswerUpdated",
|
|
18
|
+
"type": "event"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"anonymous": false,
|
|
22
|
+
"inputs": [
|
|
23
|
+
{ "indexed": true, "internalType": "uint256", "name": "roundId", "type": "uint256" },
|
|
24
|
+
{ "indexed": true, "internalType": "address", "name": "startedBy", "type": "address" },
|
|
25
|
+
{ "indexed": false, "internalType": "uint256", "name": "startedAt", "type": "uint256" }
|
|
26
|
+
],
|
|
27
|
+
"name": "NewRound",
|
|
28
|
+
"type": "event"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"anonymous": false,
|
|
32
|
+
"inputs": [
|
|
33
|
+
{ "indexed": true, "internalType": "address", "name": "from", "type": "address" },
|
|
34
|
+
{ "indexed": true, "internalType": "address", "name": "to", "type": "address" }
|
|
35
|
+
],
|
|
36
|
+
"name": "OwnershipTransferRequested",
|
|
37
|
+
"type": "event"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"anonymous": false,
|
|
41
|
+
"inputs": [
|
|
42
|
+
{ "indexed": true, "internalType": "address", "name": "from", "type": "address" },
|
|
43
|
+
{ "indexed": true, "internalType": "address", "name": "to", "type": "address" }
|
|
44
|
+
],
|
|
45
|
+
"name": "OwnershipTransferred",
|
|
46
|
+
"type": "event"
|
|
47
|
+
},
|
|
48
|
+
{ "inputs": [], "name": "acceptOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
|
|
49
|
+
{
|
|
50
|
+
"inputs": [],
|
|
51
|
+
"name": "accessController",
|
|
52
|
+
"outputs": [{ "internalType": "contract AccessControllerInterface", "name": "", "type": "address" }],
|
|
53
|
+
"stateMutability": "view",
|
|
54
|
+
"type": "function"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"inputs": [],
|
|
58
|
+
"name": "aggregator",
|
|
59
|
+
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
|
60
|
+
"stateMutability": "view",
|
|
61
|
+
"type": "function"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"inputs": [{ "internalType": "address", "name": "_aggregator", "type": "address" }],
|
|
65
|
+
"name": "confirmAggregator",
|
|
66
|
+
"outputs": [],
|
|
67
|
+
"stateMutability": "nonpayable",
|
|
68
|
+
"type": "function"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"inputs": [],
|
|
72
|
+
"name": "decimals",
|
|
73
|
+
"outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }],
|
|
74
|
+
"stateMutability": "view",
|
|
75
|
+
"type": "function"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"inputs": [],
|
|
79
|
+
"name": "description",
|
|
80
|
+
"outputs": [{ "internalType": "string", "name": "", "type": "string" }],
|
|
81
|
+
"stateMutability": "view",
|
|
82
|
+
"type": "function"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"inputs": [{ "internalType": "uint256", "name": "_roundId", "type": "uint256" }],
|
|
86
|
+
"name": "getAnswer",
|
|
87
|
+
"outputs": [{ "internalType": "int256", "name": "", "type": "int256" }],
|
|
88
|
+
"stateMutability": "view",
|
|
89
|
+
"type": "function"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"inputs": [{ "internalType": "uint80", "name": "_roundId", "type": "uint80" }],
|
|
93
|
+
"name": "getRoundData",
|
|
94
|
+
"outputs": [
|
|
95
|
+
{ "internalType": "uint80", "name": "roundId", "type": "uint80" },
|
|
96
|
+
{ "internalType": "int256", "name": "answer", "type": "int256" },
|
|
97
|
+
{ "internalType": "uint256", "name": "startedAt", "type": "uint256" },
|
|
98
|
+
{ "internalType": "uint256", "name": "updatedAt", "type": "uint256" },
|
|
99
|
+
{ "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }
|
|
100
|
+
],
|
|
101
|
+
"stateMutability": "view",
|
|
102
|
+
"type": "function"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"inputs": [{ "internalType": "uint256", "name": "_roundId", "type": "uint256" }],
|
|
106
|
+
"name": "getTimestamp",
|
|
107
|
+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
|
|
108
|
+
"stateMutability": "view",
|
|
109
|
+
"type": "function"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"inputs": [],
|
|
113
|
+
"name": "latestAnswer",
|
|
114
|
+
"outputs": [{ "internalType": "int256", "name": "", "type": "int256" }],
|
|
115
|
+
"stateMutability": "view",
|
|
116
|
+
"type": "function"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"inputs": [],
|
|
120
|
+
"name": "latestRound",
|
|
121
|
+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
|
|
122
|
+
"stateMutability": "view",
|
|
123
|
+
"type": "function"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"inputs": [],
|
|
127
|
+
"name": "latestRoundData",
|
|
128
|
+
"outputs": [
|
|
129
|
+
{ "internalType": "uint80", "name": "roundId", "type": "uint80" },
|
|
130
|
+
{ "internalType": "int256", "name": "answer", "type": "int256" },
|
|
131
|
+
{ "internalType": "uint256", "name": "startedAt", "type": "uint256" },
|
|
132
|
+
{ "internalType": "uint256", "name": "updatedAt", "type": "uint256" },
|
|
133
|
+
{ "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }
|
|
134
|
+
],
|
|
135
|
+
"stateMutability": "view",
|
|
136
|
+
"type": "function"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"inputs": [],
|
|
140
|
+
"name": "latestTimestamp",
|
|
141
|
+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
|
|
142
|
+
"stateMutability": "view",
|
|
143
|
+
"type": "function"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"inputs": [],
|
|
147
|
+
"name": "owner",
|
|
148
|
+
"outputs": [{ "internalType": "address payable", "name": "", "type": "address" }],
|
|
149
|
+
"stateMutability": "view",
|
|
150
|
+
"type": "function"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"inputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }],
|
|
154
|
+
"name": "phaseAggregators",
|
|
155
|
+
"outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "", "type": "address" }],
|
|
156
|
+
"stateMutability": "view",
|
|
157
|
+
"type": "function"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"inputs": [],
|
|
161
|
+
"name": "phaseId",
|
|
162
|
+
"outputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }],
|
|
163
|
+
"stateMutability": "view",
|
|
164
|
+
"type": "function"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"inputs": [{ "internalType": "address", "name": "_aggregator", "type": "address" }],
|
|
168
|
+
"name": "proposeAggregator",
|
|
169
|
+
"outputs": [],
|
|
170
|
+
"stateMutability": "nonpayable",
|
|
171
|
+
"type": "function"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"inputs": [],
|
|
175
|
+
"name": "proposedAggregator",
|
|
176
|
+
"outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "", "type": "address" }],
|
|
177
|
+
"stateMutability": "view",
|
|
178
|
+
"type": "function"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"inputs": [{ "internalType": "uint80", "name": "_roundId", "type": "uint80" }],
|
|
182
|
+
"name": "proposedGetRoundData",
|
|
183
|
+
"outputs": [
|
|
184
|
+
{ "internalType": "uint80", "name": "roundId", "type": "uint80" },
|
|
185
|
+
{ "internalType": "int256", "name": "answer", "type": "int256" },
|
|
186
|
+
{ "internalType": "uint256", "name": "startedAt", "type": "uint256" },
|
|
187
|
+
{ "internalType": "uint256", "name": "updatedAt", "type": "uint256" },
|
|
188
|
+
{ "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }
|
|
189
|
+
],
|
|
190
|
+
"stateMutability": "view",
|
|
191
|
+
"type": "function"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"inputs": [],
|
|
195
|
+
"name": "proposedLatestRoundData",
|
|
196
|
+
"outputs": [
|
|
197
|
+
{ "internalType": "uint80", "name": "roundId", "type": "uint80" },
|
|
198
|
+
{ "internalType": "int256", "name": "answer", "type": "int256" },
|
|
199
|
+
{ "internalType": "uint256", "name": "startedAt", "type": "uint256" },
|
|
200
|
+
{ "internalType": "uint256", "name": "updatedAt", "type": "uint256" },
|
|
201
|
+
{ "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }
|
|
202
|
+
],
|
|
203
|
+
"stateMutability": "view",
|
|
204
|
+
"type": "function"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"inputs": [{ "internalType": "address", "name": "_accessController", "type": "address" }],
|
|
208
|
+
"name": "setController",
|
|
209
|
+
"outputs": [],
|
|
210
|
+
"stateMutability": "nonpayable",
|
|
211
|
+
"type": "function"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"inputs": [{ "internalType": "address", "name": "_to", "type": "address" }],
|
|
215
|
+
"name": "transferOwnership",
|
|
216
|
+
"outputs": [],
|
|
217
|
+
"stateMutability": "nonpayable",
|
|
218
|
+
"type": "function"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"inputs": [],
|
|
222
|
+
"name": "version",
|
|
223
|
+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
|
|
224
|
+
"stateMutability": "view",
|
|
225
|
+
"type": "function"
|
|
226
|
+
}
|
|
227
|
+
]
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { AptosBindOptions } from './bind-options'
|
|
2
|
+
import { AptosContext } from './context'
|
|
3
|
+
import { ProcessResult } from './index'
|
|
4
|
+
import Long from 'long'
|
|
5
|
+
|
|
6
|
+
type IndexConfigure = {
|
|
7
|
+
startSeqNumber: Long
|
|
8
|
+
endSeqNumber?: Long
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class AptosBaseProcessor {
|
|
12
|
+
public transactionHanlder: (transaction: any, ctx: AptosContext) => void
|
|
13
|
+
address: string
|
|
14
|
+
config: IndexConfigure = { startSeqNumber: new Long(0) }
|
|
15
|
+
|
|
16
|
+
constructor(options: AptosBindOptions) {
|
|
17
|
+
if (options) {
|
|
18
|
+
this.bind(options)
|
|
19
|
+
}
|
|
20
|
+
global.PROCESSOR_STATE.aptosProcessors.push(this)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
bind(options: AptosBindOptions) {
|
|
24
|
+
this.address = options.address
|
|
25
|
+
if (options.startBlock) {
|
|
26
|
+
this.startSlot(options.startBlock)
|
|
27
|
+
}
|
|
28
|
+
if (options.endBlock) {
|
|
29
|
+
this.endBlock(options.endBlock)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public onTransaction(handler: (transaction: any, ctx: AptosContext) => void) {
|
|
34
|
+
if (!this.isBind()) {
|
|
35
|
+
throw new Error("Processor doesn't bind to an address")
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
this.transactionHanlder = handler
|
|
39
|
+
|
|
40
|
+
return this
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public handleTransaction(txn: any): ProcessResult | null {
|
|
44
|
+
const ctx = new AptosContext(this.address)
|
|
45
|
+
|
|
46
|
+
if (txn) {
|
|
47
|
+
this.transactionHanlder(txn, ctx)
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
gauges: ctx.gauges,
|
|
51
|
+
counters: ctx.counters,
|
|
52
|
+
logs: [],
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public isBind() {
|
|
57
|
+
return this.address !== null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public startSlot(startSlot: Long | number) {
|
|
61
|
+
if (typeof startSlot === 'number') {
|
|
62
|
+
startSlot = Long.fromNumber(startSlot)
|
|
63
|
+
}
|
|
64
|
+
this.config.startSeqNumber = startSlot
|
|
65
|
+
return this
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public endBlock(endBlock: Long | number) {
|
|
69
|
+
if (typeof endBlock === 'number') {
|
|
70
|
+
endBlock = Long.fromNumber(endBlock)
|
|
71
|
+
}
|
|
72
|
+
this.config.endSeqNumber = endBlock
|
|
73
|
+
return this
|
|
74
|
+
}
|
|
75
|
+
}
|
package/src/bind-options.ts
CHANGED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* Autogenerated file. Do not edit manually. */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
import { Log } from "@ethersproject/providers";
|
|
5
|
+
import {
|
|
6
|
+
getEACAggregatorProxyContract,
|
|
7
|
+
AnswerUpdatedEventObject,
|
|
8
|
+
NewRoundEventObject,
|
|
9
|
+
OwnershipTransferRequestedEventObject,
|
|
10
|
+
OwnershipTransferredEventObject,
|
|
11
|
+
} from ".";
|
|
12
|
+
const mockField = {
|
|
13
|
+
blockHash:
|
|
14
|
+
"0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
15
|
+
blockNumber: 0,
|
|
16
|
+
logIndex: 0,
|
|
17
|
+
removed: false,
|
|
18
|
+
transactionHash:
|
|
19
|
+
"0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
20
|
+
transactionIndex: 0,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function mockAnswerUpdatedLog(
|
|
24
|
+
contractAddress: string,
|
|
25
|
+
event: AnswerUpdatedEventObject
|
|
26
|
+
): Log {
|
|
27
|
+
const contract = getEACAggregatorProxyContract(contractAddress);
|
|
28
|
+
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
29
|
+
contract.rawContract.interface.getEvent("AnswerUpdated"),
|
|
30
|
+
Object.values(event)
|
|
31
|
+
);
|
|
32
|
+
return {
|
|
33
|
+
...mockField,
|
|
34
|
+
address: contractAddress,
|
|
35
|
+
data: encodedLog.data,
|
|
36
|
+
topics: encodedLog.topics,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function mockNewRoundLog(
|
|
41
|
+
contractAddress: string,
|
|
42
|
+
event: NewRoundEventObject
|
|
43
|
+
): Log {
|
|
44
|
+
const contract = getEACAggregatorProxyContract(contractAddress);
|
|
45
|
+
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
46
|
+
contract.rawContract.interface.getEvent("NewRound"),
|
|
47
|
+
Object.values(event)
|
|
48
|
+
);
|
|
49
|
+
return {
|
|
50
|
+
...mockField,
|
|
51
|
+
address: contractAddress,
|
|
52
|
+
data: encodedLog.data,
|
|
53
|
+
topics: encodedLog.topics,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function mockOwnershipTransferRequestedLog(
|
|
58
|
+
contractAddress: string,
|
|
59
|
+
event: OwnershipTransferRequestedEventObject
|
|
60
|
+
): Log {
|
|
61
|
+
const contract = getEACAggregatorProxyContract(contractAddress);
|
|
62
|
+
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
63
|
+
contract.rawContract.interface.getEvent("OwnershipTransferRequested"),
|
|
64
|
+
Object.values(event)
|
|
65
|
+
);
|
|
66
|
+
return {
|
|
67
|
+
...mockField,
|
|
68
|
+
address: contractAddress,
|
|
69
|
+
data: encodedLog.data,
|
|
70
|
+
topics: encodedLog.topics,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function mockOwnershipTransferredLog(
|
|
75
|
+
contractAddress: string,
|
|
76
|
+
event: OwnershipTransferredEventObject
|
|
77
|
+
): Log {
|
|
78
|
+
const contract = getEACAggregatorProxyContract(contractAddress);
|
|
79
|
+
const encodedLog = contract.rawContract.interface.encodeEventLog(
|
|
80
|
+
contract.rawContract.interface.getEvent("OwnershipTransferred"),
|
|
81
|
+
Object.values(event)
|
|
82
|
+
);
|
|
83
|
+
return {
|
|
84
|
+
...mockField,
|
|
85
|
+
address: contractAddress,
|
|
86
|
+
data: encodedLog.data,
|
|
87
|
+
topics: encodedLog.topics,
|
|
88
|
+
};
|
|
89
|
+
}
|