@sentio/sdk 1.17.2 → 1.18.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.
Files changed (247) hide show
  1. package/lib/binds.d.ts +2 -3
  2. package/lib/binds.js +1 -1
  3. package/lib/binds.js.map +1 -1
  4. package/lib/builtin/eacaggregatorproxy/test-utils.js +4 -4
  5. package/lib/builtin/eacaggregatorproxy/test-utils.js.map +1 -1
  6. package/lib/builtin/erc20/test-utils.js +3 -3
  7. package/lib/builtin/erc20/test-utils.js.map +1 -1
  8. package/lib/builtin/erc20bytes/test-utils.js +2 -2
  9. package/lib/builtin/erc20bytes/test-utils.js.map +1 -1
  10. package/lib/builtin/index.d.ts +5 -0
  11. package/lib/builtin/index.js +32 -0
  12. package/lib/builtin/index.js.map +1 -0
  13. package/lib/{solana/builtin → builtin/solana}/index.d.ts +0 -0
  14. package/lib/{solana/builtin → builtin/solana}/index.js +0 -0
  15. package/lib/{solana/builtin → builtin/solana}/index.js.map +1 -1
  16. package/lib/{solana/builtin → builtin/solana}/spl-token-processor.d.ts +1 -3
  17. package/lib/{solana/builtin → builtin/solana}/spl-token-processor.js +2 -2
  18. package/lib/builtin/solana/spl-token-processor.js.map +1 -0
  19. package/lib/{solana/builtin → builtin/solana}/types.d.ts +27 -27
  20. package/lib/{solana/builtin → builtin/solana}/types.js +0 -0
  21. package/lib/{solana/builtin → builtin/solana}/types.js.map +1 -1
  22. package/lib/{solana/builtin → builtin/solana}/wormhole-processor.d.ts +1 -3
  23. package/lib/{solana/builtin → builtin/solana}/wormhole-processor.js +2 -2
  24. package/lib/builtin/solana/wormhole-processor.js.map +1 -0
  25. package/lib/builtin/weth9/test-utils.js +4 -4
  26. package/lib/builtin/weth9/test-utils.js.map +1 -1
  27. package/lib/cli/webpack.config.js +1 -1
  28. package/lib/{aptos-processor.d.ts → core/aptos-processor.d.ts} +3 -2
  29. package/lib/{aptos-processor.js → core/aptos-processor.js} +4 -2
  30. package/lib/core/aptos-processor.js.map +1 -0
  31. package/lib/{base-processor-template.d.ts → core/base-processor-template.d.ts} +1 -1
  32. package/lib/{base-processor-template.js → core/base-processor-template.js} +0 -0
  33. package/lib/core/base-processor-template.js.map +1 -0
  34. package/lib/{base-processor.d.ts → core/base-processor.d.ts} +2 -2
  35. package/lib/{base-processor.js → core/base-processor.js} +0 -0
  36. package/lib/core/base-processor.js.map +1 -0
  37. package/lib/{bind-options.d.ts → core/bind-options.d.ts} +0 -0
  38. package/lib/{bind-options.js → core/bind-options.js} +0 -0
  39. package/lib/core/bind-options.js.map +1 -0
  40. package/lib/{context.d.ts → core/context.d.ts} +7 -4
  41. package/lib/{context.js → core/context.js} +12 -6
  42. package/lib/core/context.js.map +1 -0
  43. package/lib/{generic-processor.d.ts → core/generic-processor.d.ts} +0 -0
  44. package/lib/{generic-processor.js → core/generic-processor.js} +2 -2
  45. package/lib/core/generic-processor.js.map +1 -0
  46. package/lib/{test → core}/generic-processor.test.d.ts +0 -0
  47. package/lib/{test → core}/generic-processor.test.js +4 -5
  48. package/lib/core/generic-processor.test.js.map +1 -0
  49. package/lib/core/index.d.ts +12 -0
  50. package/lib/core/index.js +38 -0
  51. package/lib/core/index.js.map +1 -0
  52. package/lib/{meter.d.ts → core/meter.d.ts} +1 -1
  53. package/lib/{meter.js → core/meter.js} +11 -14
  54. package/lib/core/meter.js.map +1 -0
  55. package/lib/{meter.test.d.ts → core/meter.test.d.ts} +0 -0
  56. package/lib/{meter.test.js → core/meter.test.js} +0 -0
  57. package/lib/core/meter.test.js.map +1 -0
  58. package/lib/{numberish.d.ts → core/numberish.d.ts} +1 -1
  59. package/lib/{numberish.js → core/numberish.js} +1 -1
  60. package/lib/core/numberish.js.map +1 -0
  61. package/lib/{numberish.test.d.ts → core/numberish.test.d.ts} +0 -0
  62. package/lib/{numberish.test.js → core/numberish.test.js} +4 -4
  63. package/lib/core/numberish.test.js.map +1 -0
  64. package/lib/{solana-processor.d.ts → core/solana-processor.d.ts} +2 -2
  65. package/lib/{solana-processor.js → core/solana-processor.js} +2 -2
  66. package/lib/core/solana-processor.js.map +1 -0
  67. package/lib/{sui-processor.d.ts → core/sui-processor.d.ts} +2 -2
  68. package/lib/{sui-processor.js → core/sui-processor.js} +2 -2
  69. package/lib/core/sui-processor.js.map +1 -0
  70. package/lib/{trace.d.ts → core/trace.d.ts} +0 -0
  71. package/lib/{trace.js → core/trace.js} +0 -0
  72. package/lib/core/trace.js.map +1 -0
  73. package/lib/error.d.ts +1 -1
  74. package/lib/error.js.map +1 -1
  75. package/lib/index.d.ts +1 -12
  76. package/lib/index.js +2 -34
  77. package/lib/index.js.map +1 -1
  78. package/lib/processor-state.d.ts +1 -6
  79. package/lib/processor-state.js.map +1 -1
  80. package/lib/service.js +21 -54
  81. package/lib/service.js.map +1 -1
  82. package/lib/target-ethers-sentio/codegen.js +2 -1
  83. package/lib/target-ethers-sentio/codegen.js.map +1 -1
  84. package/lib/{test → testing}/index.d.ts +0 -1
  85. package/lib/{test → testing}/index.js +2 -3
  86. package/lib/testing/index.js.map +1 -0
  87. package/lib/{test → testing}/metric-utils.d.ts +1 -1
  88. package/lib/{test → testing}/metric-utils.js +0 -0
  89. package/lib/testing/metric-utils.js.map +1 -0
  90. package/lib/{test → testing}/test-processor-server.d.ts +1 -1
  91. package/lib/{test → testing}/test-processor-server.js +2 -2
  92. package/lib/testing/test-processor-server.js.map +1 -0
  93. package/lib/{test → testing}/test-provider.d.ts +0 -0
  94. package/lib/{test → testing}/test-provider.js +5 -3
  95. package/lib/testing/test-provider.js.map +1 -0
  96. package/lib/{test → tests}/aptos.test.d.ts +0 -0
  97. package/lib/{test → tests}/aptos.test.js +10 -3
  98. package/lib/tests/aptos.test.js.map +1 -0
  99. package/lib/{test → tests}/codegen.test.d.ts +0 -0
  100. package/lib/{test → tests}/codegen.test.js +0 -0
  101. package/lib/tests/codegen.test.js.map +1 -0
  102. package/lib/{test → tests}/erc20-template.test.d.ts +0 -0
  103. package/lib/{test → tests}/erc20-template.test.js +2 -2
  104. package/lib/tests/erc20-template.test.js.map +1 -0
  105. package/lib/{test → tests}/erc20.d.ts +0 -0
  106. package/lib/{test → tests}/erc20.js +0 -0
  107. package/lib/tests/erc20.js.map +1 -0
  108. package/lib/{test → tests}/erc20.test.d.ts +0 -0
  109. package/lib/{test → tests}/erc20.test.js +6 -7
  110. package/lib/tests/erc20.test.js.map +1 -0
  111. package/lib/{test → tests}/error-capture.test.d.ts +0 -0
  112. package/lib/{test → tests}/error-capture.test.js +4 -4
  113. package/lib/tests/error-capture.test.js.map +1 -0
  114. package/lib/{test → tests}/solana.test.d.ts +0 -0
  115. package/lib/{test → tests}/solana.test.js +6 -7
  116. package/lib/tests/solana.test.js.map +1 -0
  117. package/lib/{test → tests}/souffl3.d.ts +0 -0
  118. package/lib/{test → tests}/souffl3.js +2 -2
  119. package/lib/tests/souffl3.js.map +1 -0
  120. package/lib/{test → tests}/sui.test.d.ts +0 -0
  121. package/lib/{test → tests}/sui.test.js +10 -4
  122. package/lib/tests/sui.test.js.map +1 -0
  123. package/lib/{test → tests}/types/basic_1.d.ts +0 -0
  124. package/lib/{test → tests}/types/basic_1.js +0 -0
  125. package/lib/tests/types/basic_1.js.map +1 -0
  126. package/lib/{test → tests}/types/basic_1_processor.d.ts +0 -0
  127. package/lib/{test → tests}/types/basic_1_processor.js +0 -0
  128. package/lib/tests/types/basic_1_processor.js.map +1 -0
  129. package/lib/{test → tests}/wormhole-token-bridge.d.ts +0 -0
  130. package/lib/{test → tests}/wormhole-token-bridge.js +3 -4
  131. package/lib/tests/wormhole-token-bridge.js.map +1 -0
  132. package/lib/utils/chain.d.ts +7 -0
  133. package/lib/utils/{chainmap.js → chain.js} +12 -5
  134. package/lib/utils/chain.js.map +1 -0
  135. package/lib/utils/{convert.d.ts → conversion.d.ts} +1 -1
  136. package/lib/utils/{convert.js → conversion.js} +1 -1
  137. package/lib/utils/conversion.js.map +1 -0
  138. package/lib/utils/dex-price.d.ts +5 -5
  139. package/lib/utils/dex-price.js +2 -2
  140. package/lib/utils/dex-price.js.map +1 -1
  141. package/lib/utils/dex-price.test.js +2 -2
  142. package/lib/utils/dex-price.test.js.map +1 -1
  143. package/lib/utils/erc20.test.js +6 -5
  144. package/lib/utils/erc20.test.js.map +1 -1
  145. package/lib/utils/index.d.ts +4 -5
  146. package/lib/utils/index.js +28 -16
  147. package/lib/utils/index.js.map +1 -1
  148. package/lib/utils/{erc20.d.ts → token.d.ts} +1 -1
  149. package/lib/utils/{erc20.js → token.js} +4 -10
  150. package/lib/utils/token.js.map +1 -0
  151. package/package.json +5 -3
  152. package/src/binds.ts +2 -3
  153. package/src/builtin/eacaggregatorproxy/test-utils.ts +4 -4
  154. package/src/builtin/erc20/test-utils.ts +3 -3
  155. package/src/builtin/erc20bytes/test-utils.ts +2 -2
  156. package/src/builtin/index.ts +5 -0
  157. package/src/{solana/builtin → builtin/solana}/index.ts +0 -0
  158. package/src/{solana/builtin → builtin/solana}/spl-token-processor.ts +1 -3
  159. package/src/{solana/builtin → builtin/solana}/types.ts +0 -0
  160. package/src/{solana/builtin → builtin/solana}/wormhole-processor.ts +1 -3
  161. package/src/builtin/weth9/test-utils.ts +4 -4
  162. package/src/cli/webpack.config.js +1 -1
  163. package/src/{aptos-processor.ts → core/aptos-processor.ts} +5 -3
  164. package/src/{base-processor-template.ts → core/base-processor-template.ts} +2 -2
  165. package/src/{base-processor.ts → core/base-processor.ts} +2 -2
  166. package/src/{bind-options.ts → core/bind-options.ts} +0 -0
  167. package/src/{context.ts → core/context.ts} +13 -7
  168. package/src/{test → core}/generic-processor.test.ts +2 -3
  169. package/src/{generic-processor.ts → core/generic-processor.ts} +2 -2
  170. package/src/core/index.ts +15 -0
  171. package/src/{meter.test.ts → core/meter.test.ts} +0 -0
  172. package/src/{meter.ts → core/meter.ts} +11 -11
  173. package/src/{numberish.test.ts → core/numberish.test.ts} +2 -2
  174. package/src/{numberish.ts → core/numberish.ts} +1 -1
  175. package/src/{solana-processor.ts → core/solana-processor.ts} +3 -3
  176. package/src/{sui-processor.ts → core/sui-processor.ts} +3 -3
  177. package/src/{trace.ts → core/trace.ts} +0 -0
  178. package/src/error.ts +1 -1
  179. package/src/index.ts +1 -13
  180. package/src/processor-state.ts +9 -6
  181. package/src/service.ts +32 -54
  182. package/src/target-ethers-sentio/codegen.ts +3 -1
  183. package/src/{test → testing}/index.ts +2 -1
  184. package/src/{test → testing}/metric-utils.ts +1 -1
  185. package/src/{test → testing}/test-processor-server.ts +2 -2
  186. package/src/{test → testing}/test-provider.ts +4 -2
  187. package/src/{test → tests}/abis/evm/CommitmentPool.json +0 -0
  188. package/src/{test → tests}/abis/evm/Seaport.json +0 -0
  189. package/src/{test → tests}/abis/evm/anyswapRouter.json +0 -0
  190. package/src/{test → tests}/abis/solana/basic_1.json +0 -0
  191. package/src/{test → tests}/aptos.test.ts +6 -2
  192. package/src/{test → tests}/codegen.test.ts +0 -0
  193. package/src/{test → tests}/erc20-template.test.ts +1 -1
  194. package/src/{test → tests}/erc20.test.ts +2 -3
  195. package/src/{test → tests}/erc20.ts +0 -0
  196. package/src/{test → tests}/error-capture.test.ts +4 -4
  197. package/src/{test → tests}/solana.test.ts +3 -4
  198. package/src/{test → tests}/souffl3.ts +1 -2
  199. package/src/{test → tests}/sui.test.ts +6 -3
  200. package/src/{test → tests}/types/basic_1.ts +0 -0
  201. package/src/{test → tests}/types/basic_1_processor.ts +0 -0
  202. package/src/{test → tests}/wormhole-token-bridge.ts +1 -2
  203. package/src/utils/{chainmap.ts → chain.ts} +13 -3
  204. package/src/utils/{convert.ts → conversion.ts} +1 -1
  205. package/src/utils/dex-price.test.ts +2 -1
  206. package/src/utils/dex-price.ts +6 -6
  207. package/src/utils/erc20.test.ts +6 -3
  208. package/src/utils/index.ts +4 -5
  209. package/src/utils/{erc20.ts → token.ts} +2 -2
  210. package/template/src/processor.test.ts +1 -2
  211. package/template/src/processor.ts +5 -5
  212. package/lib/aptos-processor.js.map +0 -1
  213. package/lib/base-processor-template.js.map +0 -1
  214. package/lib/base-processor.js.map +0 -1
  215. package/lib/bind-options.js.map +0 -1
  216. package/lib/context.js.map +0 -1
  217. package/lib/generic-processor.js.map +0 -1
  218. package/lib/meter.js.map +0 -1
  219. package/lib/meter.test.js.map +0 -1
  220. package/lib/numberish.js.map +0 -1
  221. package/lib/numberish.test.js.map +0 -1
  222. package/lib/solana/builtin/spl-token-processor.js.map +0 -1
  223. package/lib/solana/builtin/wormhole-processor.js.map +0 -1
  224. package/lib/solana-processor.js.map +0 -1
  225. package/lib/sui-processor.js.map +0 -1
  226. package/lib/test/aptos.test.js.map +0 -1
  227. package/lib/test/codegen.test.js.map +0 -1
  228. package/lib/test/erc20-template.test.js.map +0 -1
  229. package/lib/test/erc20.js.map +0 -1
  230. package/lib/test/erc20.test.js.map +0 -1
  231. package/lib/test/error-capture.test.js.map +0 -1
  232. package/lib/test/generic-processor.test.js.map +0 -1
  233. package/lib/test/index.js.map +0 -1
  234. package/lib/test/metric-utils.js.map +0 -1
  235. package/lib/test/solana.test.js.map +0 -1
  236. package/lib/test/souffl3.js.map +0 -1
  237. package/lib/test/sui.test.js.map +0 -1
  238. package/lib/test/test-processor-server.js.map +0 -1
  239. package/lib/test/test-provider.js.map +0 -1
  240. package/lib/test/types/basic_1.js.map +0 -1
  241. package/lib/test/types/basic_1_processor.js.map +0 -1
  242. package/lib/test/wormhole-token-bridge.js.map +0 -1
  243. package/lib/trace.js.map +0 -1
  244. package/lib/utils/chainmap.d.ts +0 -2
  245. package/lib/utils/chainmap.js.map +0 -1
  246. package/lib/utils/convert.js.map +0 -1
  247. package/lib/utils/erc20.js.map +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
3
  "license": "Apache-2.0",
4
- "version": "1.17.2",
4
+ "version": "1.18.1",
5
5
  "scripts": {
6
6
  "compile_target": "yarn tsc -b src/target-ethers-sentio/tsconfig.json",
7
7
  "compile": "tsc -p . && cp src/cli/webpack.config.js lib/cli && cp src/utils/*.csv lib/utils",
@@ -15,8 +15,9 @@
15
15
  "gen": "yarn compile_target && yarn gen_bultin_evm && yarn gen_test_abi",
16
16
  "gen_test_abi": "yarn gen_solana_abi",
17
17
  "gen_bultin_evm": "typechain --target lib/target-ethers-sentio --out-dir src/builtin/internal 'src/abis/*.json'",
18
- "gen_solana_abi": "ts-node src/cli/solana-code-gen.ts src/test types",
19
- "postbuild": "echo || clear-package-json package.json -o ./lib/package.json && cp release.config.js ./lib"
18
+ "gen_solana_abi": "ts-node src/cli/solana-code-gen.ts src/tests types",
19
+ "postbuild": "echo || clear-package-json package.json -o ./lib/package.json && cp release.config.js ./lib",
20
+ "docs": "typedoc --options typedoc.json"
20
21
  },
21
22
  "dependencies": {
22
23
  "@ethersproject/providers": "~5.7.0",
@@ -63,6 +64,7 @@
63
64
  "ts-jest": "^29.0.0",
64
65
  "ts-node": "^10.8.0",
65
66
  "tsconfig-paths": "^4.0.0",
67
+ "typedoc": "^0.23.15",
66
68
  "typescript": "^4.8.0"
67
69
  },
68
70
  "bin": {
package/src/binds.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { BindOptions, getOptionsSignature } from './bind-options'
2
- import { BaseProcessor } from './base-processor'
1
+ import { BindOptions, getOptionsSignature } from './core/bind-options'
2
+ import { BaseProcessor, ContractView } from './core'
3
3
  import { Networkish } from '@ethersproject/networks'
4
4
  import { getNetwork } from '@ethersproject/providers'
5
- import { ContractView } from './context'
6
5
  import { BaseContract } from 'ethers'
7
6
  import { ContractNamer } from './contract-namer'
8
7
 
@@ -27,7 +27,7 @@ export function mockAnswerUpdatedLog(
27
27
  const contract = getEACAggregatorProxyContract(contractAddress);
28
28
  const encodedLog = contract.rawContract.interface.encodeEventLog(
29
29
  contract.rawContract.interface.getEvent("AnswerUpdated"),
30
- Object.values(event)
30
+ [event.current, event.roundId, event.updatedAt]
31
31
  );
32
32
  return {
33
33
  ...mockField,
@@ -44,7 +44,7 @@ export function mockNewRoundLog(
44
44
  const contract = getEACAggregatorProxyContract(contractAddress);
45
45
  const encodedLog = contract.rawContract.interface.encodeEventLog(
46
46
  contract.rawContract.interface.getEvent("NewRound"),
47
- Object.values(event)
47
+ [event.roundId, event.startedBy, event.startedAt]
48
48
  );
49
49
  return {
50
50
  ...mockField,
@@ -61,7 +61,7 @@ export function mockOwnershipTransferRequestedLog(
61
61
  const contract = getEACAggregatorProxyContract(contractAddress);
62
62
  const encodedLog = contract.rawContract.interface.encodeEventLog(
63
63
  contract.rawContract.interface.getEvent("OwnershipTransferRequested"),
64
- Object.values(event)
64
+ [event.from, event.to]
65
65
  );
66
66
  return {
67
67
  ...mockField,
@@ -78,7 +78,7 @@ export function mockOwnershipTransferredLog(
78
78
  const contract = getEACAggregatorProxyContract(contractAddress);
79
79
  const encodedLog = contract.rawContract.interface.encodeEventLog(
80
80
  contract.rawContract.interface.getEvent("OwnershipTransferred"),
81
- Object.values(event)
81
+ [event.from, event.to]
82
82
  );
83
83
  return {
84
84
  ...mockField,
@@ -26,7 +26,7 @@ export function mockApprovalLog(
26
26
  const contract = getERC20Contract(contractAddress);
27
27
  const encodedLog = contract.rawContract.interface.encodeEventLog(
28
28
  contract.rawContract.interface.getEvent("Approval"),
29
- Object.values(event)
29
+ [event.owner, event.spender, event.value]
30
30
  );
31
31
  return {
32
32
  ...mockField,
@@ -43,7 +43,7 @@ export function mockOwnershipTransferredLog(
43
43
  const contract = getERC20Contract(contractAddress);
44
44
  const encodedLog = contract.rawContract.interface.encodeEventLog(
45
45
  contract.rawContract.interface.getEvent("OwnershipTransferred"),
46
- Object.values(event)
46
+ [event.previousOwner, event.newOwner]
47
47
  );
48
48
  return {
49
49
  ...mockField,
@@ -60,7 +60,7 @@ export function mockTransferLog(
60
60
  const contract = getERC20Contract(contractAddress);
61
61
  const encodedLog = contract.rawContract.interface.encodeEventLog(
62
62
  contract.rawContract.interface.getEvent("Transfer"),
63
- Object.values(event)
63
+ [event.from, event.to, event.value]
64
64
  );
65
65
  return {
66
66
  ...mockField,
@@ -25,7 +25,7 @@ export function mockApprovalLog(
25
25
  const contract = getERC20BytesContract(contractAddress);
26
26
  const encodedLog = contract.rawContract.interface.encodeEventLog(
27
27
  contract.rawContract.interface.getEvent("Approval"),
28
- Object.values(event)
28
+ [event.owner, event.spender, event.value]
29
29
  );
30
30
  return {
31
31
  ...mockField,
@@ -42,7 +42,7 @@ export function mockTransferLog(
42
42
  const contract = getERC20BytesContract(contractAddress);
43
43
  const encodedLog = contract.rawContract.interface.encodeEventLog(
44
44
  contract.rawContract.interface.getEvent("Transfer"),
45
- Object.values(event)
45
+ [event.from, event.to, event.value]
46
46
  );
47
47
  return {
48
48
  ...mockField,
@@ -0,0 +1,5 @@
1
+ export * as eacaggregatorproxy from './eacaggregatorproxy'
2
+ export * as erc20 from './erc20'
3
+ export * as erc20bytes from './erc20bytes'
4
+ export * as weth9 from './weth9'
5
+ export * as solana from './solana'
File without changes
@@ -1,8 +1,6 @@
1
- import { SolanaBaseProcessor } from '../../solana-processor'
2
- import { SolanaContext } from '../../context'
1
+ import { SolanaBaseProcessor, SolanaContext, SolanaBindOptions } from '@sentio/sdk'
3
2
  import { Instruction } from '@project-serum/anchor'
4
3
  import { AmountToUiAmount, Approve, ApproveChecked, Burn, BurnChecked, CloseAccount, CreateNativeMint, DefaultAccountStateExtension, FreezeAccount, GetAccountDataSize, InitializeAccount, InitializeAccount2, InitializeAccount3, InitializeImmutableOwner, InitializeMint, InitializeMintCloseAuthority, InitializeMultisig, MemoTransferExtension, MintTo, MintToChecked, Reallocate, Revoke, SyncNative, ThawAccount, Transfer, TransferChecked, TransferFeeExtension, UiAmountToAmount } from './types';
5
- import { SolanaBindOptions } from '../../bind-options';
6
4
 
7
5
  export class SPLTokenProcessor extends SolanaBaseProcessor {
8
6
  static bind(options: SolanaBindOptions): SPLTokenProcessor {
File without changes
@@ -1,6 +1,4 @@
1
- import { SolanaBaseProcessor } from '../../solana-processor'
2
- import { SolanaContext } from '../../context'
3
- import { SolanaBindOptions } from '../../bind-options'
1
+ import { SolanaBaseProcessor, SolanaContext, SolanaBindOptions } from '@sentio/sdk'
4
2
  import { Instruction } from '@project-serum/anchor'
5
3
  import * as borsh from '@project-serum/borsh'
6
4
  import bs58 from 'bs58'
@@ -27,7 +27,7 @@ export function mockApprovalLog(
27
27
  const contract = getWETH9Contract(contractAddress);
28
28
  const encodedLog = contract.rawContract.interface.encodeEventLog(
29
29
  contract.rawContract.interface.getEvent("Approval"),
30
- Object.values(event)
30
+ [event.src, event.guy, event.wad]
31
31
  );
32
32
  return {
33
33
  ...mockField,
@@ -44,7 +44,7 @@ export function mockTransferLog(
44
44
  const contract = getWETH9Contract(contractAddress);
45
45
  const encodedLog = contract.rawContract.interface.encodeEventLog(
46
46
  contract.rawContract.interface.getEvent("Transfer"),
47
- Object.values(event)
47
+ [event.src, event.dst, event.wad]
48
48
  );
49
49
  return {
50
50
  ...mockField,
@@ -61,7 +61,7 @@ export function mockDepositLog(
61
61
  const contract = getWETH9Contract(contractAddress);
62
62
  const encodedLog = contract.rawContract.interface.encodeEventLog(
63
63
  contract.rawContract.interface.getEvent("Deposit"),
64
- Object.values(event)
64
+ [event.dst, event.wad]
65
65
  );
66
66
  return {
67
67
  ...mockField,
@@ -78,7 +78,7 @@ export function mockWithdrawalLog(
78
78
  const contract = getWETH9Contract(contractAddress);
79
79
  const encodedLog = contract.rawContract.interface.encodeEventLog(
80
80
  contract.rawContract.interface.getEvent("Withdrawal"),
81
- Object.values(event)
81
+ [event.src, event.wad]
82
82
  );
83
83
  return {
84
84
  ...mockField,
@@ -36,7 +36,7 @@ module.exports = {
36
36
  if (/^@(ethersproject|solana|project-serum).*$/.test(request)) {
37
37
  return callback(null, 'commonjs ' + request)
38
38
  }
39
- if (request.startsWith("@sentio/sdk")) {
39
+ if (request.startsWith("@sentio")) {
40
40
  return callback(null, 'commonjs2 ' + request)
41
41
  }
42
42
  callback()
@@ -1,6 +1,6 @@
1
1
  import { AptosBindOptions } from './bind-options'
2
2
  import { AptosContext } from './context'
3
- import { ProcessResult } from './index'
3
+ import { ProcessResult } from '..'
4
4
  import Long from 'long'
5
5
 
6
6
  type IndexConfigure = {
@@ -11,6 +11,7 @@ type IndexConfigure = {
11
11
  export class AptosBaseProcessor {
12
12
  public transactionHanlder: (transaction: any, ctx: AptosContext) => void
13
13
  address: string
14
+ name: string
14
15
  config: IndexConfigure = { startSeqNumber: new Long(0) }
15
16
 
16
17
  constructor(options: AptosBindOptions) {
@@ -22,6 +23,7 @@ export class AptosBaseProcessor {
22
23
 
23
24
  bind(options: AptosBindOptions) {
24
25
  this.address = options.address
26
+ this.name = options.name || this.address
25
27
  if (options.startBlock) {
26
28
  this.startSlot(options.startBlock)
27
29
  }
@@ -40,8 +42,8 @@ export class AptosBaseProcessor {
40
42
  return this
41
43
  }
42
44
 
43
- public handleTransaction(txn: any): ProcessResult | null {
44
- const ctx = new AptosContext(this.address)
45
+ public handleTransaction(txn: any, slot: Long): ProcessResult | null {
46
+ const ctx = new AptosContext(this.address, slot)
45
47
 
46
48
  if (txn) {
47
49
  this.transactionHanlder(txn, ctx)
@@ -4,10 +4,10 @@ import { BaseContract, EventFilter } from 'ethers'
4
4
  import { Event } from '@ethersproject/contracts'
5
5
  import { BaseProcessor } from './base-processor'
6
6
  import { BindOptions, getOptionsSignature } from './bind-options'
7
- import { TemplateInstance } from './gen/processor/protos/processor'
7
+ import { TemplateInstance } from '../gen/processor/protos/processor'
8
8
  import Long from 'long'
9
9
  import { getNetwork } from '@ethersproject/providers'
10
- import { PromiseOrVoid } from './promise-or-void'
10
+ import { PromiseOrVoid } from '../promise-or-void'
11
11
  import { Trace } from './trace'
12
12
 
13
13
  export abstract class BaseProcessorTemplate<
@@ -5,9 +5,9 @@ import { BaseContract, EventFilter } from '@ethersproject/contracts'
5
5
  import Long from 'long'
6
6
 
7
7
  import { BoundContractView, Context, ContractView } from './context'
8
- import { ProcessResult } from './gen/processor/protos/processor'
8
+ import { ProcessResult } from '../gen/processor/protos/processor'
9
9
  import { BindInternalOptions, BindOptions } from './bind-options'
10
- import { PromiseOrVoid } from './promise-or-void'
10
+ import { PromiseOrVoid } from '../promise-or-void'
11
11
  import { Trace } from './trace'
12
12
 
13
13
  export class EventsHandler {
File without changes
@@ -1,4 +1,4 @@
1
- import { CounterResult, GaugeResult, LogResult } from './gen/processor/protos/processor'
1
+ import { CounterResult, GaugeResult, LogResult } from '../gen/processor/protos/processor'
2
2
  import { BaseContract, EventFilter } from 'ethers'
3
3
  import { Block, Log } from '@ethersproject/abstract-provider'
4
4
  import { Meter } from './meter'
@@ -31,13 +31,13 @@ export class EthContext extends BaseContext {
31
31
  this.block = block
32
32
  this.trace = trace
33
33
  if (log) {
34
- this.blockNumber = Long.fromNumber(log.blockNumber)
34
+ this.blockNumber = Long.fromNumber(log.blockNumber, true)
35
35
  this.transactionHash = log.transactionHash
36
36
  } else if (block) {
37
- this.blockNumber = Long.fromNumber(block.number)
37
+ this.blockNumber = Long.fromNumber(block.number, true)
38
38
  }
39
39
  if (trace) {
40
- this.blockNumber = Long.fromNumber(trace.blockNumber)
40
+ this.blockNumber = Long.fromNumber(trace.blockNumber, true)
41
41
  this.transactionHash = trace.transactionHash
42
42
  }
43
43
  }
@@ -100,27 +100,33 @@ export class BoundContractView<TContract extends BaseContract, TContractView ext
100
100
 
101
101
  export class SolanaContext extends BaseContext {
102
102
  address: string
103
+ blockNumber: Long
103
104
 
104
- constructor(address: string) {
105
+ constructor(address: string, slot: Long) {
105
106
  super()
106
107
  this.address = address
108
+ this.blockNumber = slot
107
109
  }
108
110
  }
109
111
 
110
112
  export class SuiContext extends BaseContext {
111
113
  address: string
114
+ blockNumber: Long
112
115
 
113
- constructor(address: string) {
116
+ constructor(address: string, slot: Long) {
114
117
  super()
115
118
  this.address = address
119
+ this.blockNumber = slot
116
120
  }
117
121
  }
118
122
 
119
123
  export class AptosContext extends BaseContext {
120
124
  address: string
125
+ blockNumber: Long
121
126
 
122
- constructor(address: string) {
127
+ constructor(address: string, slot: Long) {
123
128
  super()
124
129
  this.address = address
130
+ this.blockNumber = slot
125
131
  }
126
132
  }
@@ -4,9 +4,8 @@ import { expect } from 'chai'
4
4
 
5
5
  import { HandlerType } from '..'
6
6
 
7
- import { GenericProcessor } from '../generic-processor'
8
- import { TestProcessorServer } from './test-processor-server'
9
- import { firstCounterValue } from './metric-utils'
7
+ import { GenericProcessor } from './generic-processor'
8
+ import { TestProcessorServer, firstCounterValue } from '../testing'
10
9
 
11
10
  describe('Test Generic Processor', () => {
12
11
  const service = new TestProcessorServer(() => {
@@ -2,8 +2,8 @@ import { BaseContract } from '@ethersproject/contracts'
2
2
  import { BoundContractView, ContractView } from './context'
3
3
  import { BindOptions } from './bind-options'
4
4
  import { BaseProcessor } from './base-processor'
5
- import { getProvider } from './provider'
6
- import { addProcessor, getContractName } from './binds'
5
+ import { getProvider } from '../provider'
6
+ import { addProcessor, getContractName } from '../binds'
7
7
 
8
8
  export class GenericProcessor extends BaseProcessor<
9
9
  BaseContract,
@@ -0,0 +1,15 @@
1
+ export { BigNumber as BigDecimal } from 'bignumber.js'
2
+ export { Context, ContractView, BoundContractView, SolanaContext } from './context'
3
+ export { CounterBinding, Meter, GaugeBinding, Counter, Gauge, MetricDescriptorOption } from './meter'
4
+ export { type Numberish, toBigInteger, toMetricValue } from './numberish'
5
+
6
+ export { BindOptions, SolanaBindOptions, SuiBindOptions, AptosBindOptions } from './bind-options'
7
+
8
+ export { BaseProcessor } from './base-processor'
9
+ export { GenericProcessor } from './generic-processor'
10
+ export { BaseProcessorTemplate } from './base-processor-template'
11
+ export { SolanaBaseProcessor } from './solana-processor'
12
+ export { SuiBaseProcessor } from './sui-processor'
13
+ export { AptosBaseProcessor } from './aptos-processor'
14
+
15
+ export type { TypedCallTrace, Trace } from './trace'
File without changes
@@ -1,7 +1,7 @@
1
- import { MetricDescriptor, RecordMetaData } from './gen/processor/protos/processor'
1
+ import { MetricDescriptor, RecordMetaData } from '../gen/processor/protos/processor'
2
2
  import { AptosContext, BaseContext, Context, SolanaContext, SuiContext } from './context'
3
3
  import { toMetricValue, Numberish } from './numberish'
4
- import Long from 'long'
4
+ import { APTOS_TESTNET_ID, SOL_MAINMET_ID, SUI_DEVNET_ID } from '../utils/chain'
5
5
 
6
6
  export function normalizeName(name: string): string {
7
7
  const regex = new RegExp('![_.a-zA-Z0-9]')
@@ -40,7 +40,7 @@ function GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): Re
40
40
  if (ctx.log) {
41
41
  return {
42
42
  contractAddress: ctx.contract.rawContract.address,
43
- blockNumber: Long.fromNumber(ctx.log.blockNumber, true), // TODO need number type to be long
43
+ blockNumber: ctx.blockNumber,
44
44
  transactionIndex: ctx.log.transactionIndex,
45
45
  transactionHash: ctx.transactionHash || '',
46
46
  logIndex: ctx.log.logIndex,
@@ -52,7 +52,7 @@ function GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): Re
52
52
  if (ctx.block) {
53
53
  return {
54
54
  contractAddress: ctx.contract.rawContract.address,
55
- blockNumber: Long.fromNumber(ctx.block.number, true),
55
+ blockNumber: ctx.blockNumber,
56
56
  transactionIndex: -1,
57
57
  transactionHash: '',
58
58
  logIndex: -1,
@@ -64,7 +64,7 @@ function GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): Re
64
64
  if (ctx.trace) {
65
65
  return {
66
66
  contractAddress: ctx.contract.rawContract.address,
67
- blockNumber: Long.fromNumber(ctx.trace.blockNumber, true),
67
+ blockNumber: ctx.blockNumber,
68
68
  transactionIndex: ctx.trace.transactionPosition,
69
69
  transactionHash: ctx.transactionHash || '',
70
70
  logIndex: -1,
@@ -76,33 +76,33 @@ function GetRecordMetaData(ctx: BaseContext, metric: Metric, labels: Labels): Re
76
76
  } else if (ctx instanceof SolanaContext) {
77
77
  return {
78
78
  contractAddress: ctx.address,
79
- blockNumber: Long.ZERO, // TODO need number type to be long
79
+ blockNumber: ctx.blockNumber,
80
80
  transactionIndex: 0,
81
81
  transactionHash: '', // TODO add
82
82
  logIndex: 0,
83
- chainId: 'SOL_mainnet', // TODO set in context
83
+ chainId: SOL_MAINMET_ID, // TODO set in context
84
84
  descriptor: descriptor,
85
85
  labels: normalizeLabels(labels),
86
86
  }
87
87
  } else if (ctx instanceof SuiContext) {
88
88
  return {
89
89
  contractAddress: ctx.address,
90
- blockNumber: Long.ZERO, // TODO need number type to be long
90
+ blockNumber: ctx.blockNumber,
91
91
  transactionIndex: 0,
92
92
  transactionHash: '', // TODO
93
93
  logIndex: 0,
94
- chainId: 'SUI_devnet', // TODO set in context
94
+ chainId: SUI_DEVNET_ID, // TODO set in context
95
95
  descriptor: descriptor,
96
96
  labels: normalizeLabels(labels),
97
97
  }
98
98
  } else if (ctx instanceof AptosContext) {
99
99
  return {
100
100
  contractAddress: ctx.address,
101
- blockNumber: Long.ZERO, // TODO need number type to be long
101
+ blockNumber: ctx.blockNumber,
102
102
  transactionIndex: 0,
103
103
  transactionHash: '', // TODO
104
104
  logIndex: 0,
105
- chainId: 'aptos_devnet', // TODO set in context
105
+ chainId: APTOS_TESTNET_ID, // TODO set in context
106
106
  descriptor: descriptor,
107
107
  labels: normalizeLabels(labels),
108
108
  }
@@ -3,8 +3,8 @@ import { toBigInteger, toMetricValue } from './numberish'
3
3
  import { webcrypto } from 'crypto'
4
4
  import { BigNumber } from 'ethers'
5
5
  import { performance } from 'perf_hooks'
6
- import { BigInteger } from './gen/processor/protos/processor'
7
- import { BigDecimal } from './index'
6
+ import { BigInteger } from '../gen/processor/protos/processor'
7
+ import { BigDecimal } from '.'
8
8
 
9
9
  // TODO add test for type conversion
10
10
  describe('Numberish tests', () => {
@@ -1,5 +1,5 @@
1
1
  import { BigNumber } from 'ethers'
2
- import { BigInteger, MetricValue } from './gen/processor/protos/processor'
2
+ import { BigInteger, MetricValue } from '../gen/processor/protos/processor'
3
3
  import { BigDecimal } from '.'
4
4
  import { BN } from '@project-serum/anchor'
5
5
 
@@ -1,4 +1,4 @@
1
- import { ProcessResult } from './gen/processor/protos/processor'
1
+ import { ProcessResult } from '../gen/processor/protos/processor'
2
2
  import { SolanaContext } from './context'
3
3
  import Long from 'long'
4
4
  import { Instruction } from '@project-serum/anchor'
@@ -54,8 +54,8 @@ export class SolanaBaseProcessor {
54
54
  return this
55
55
  }
56
56
 
57
- public handleInstruction(ins: string | { type: string; info: any }): ProcessResult | null {
58
- const ctx = new SolanaContext(this.address)
57
+ public handleInstruction(ins: string | { type: string; info: any }, slot: Long): ProcessResult | null {
58
+ const ctx = new SolanaContext(this.address, slot)
59
59
  let parsedInstruction: Instruction | null = null
60
60
 
61
61
  if (ins) {
@@ -1,6 +1,6 @@
1
1
  import { SuiBindOptions } from './bind-options'
2
2
  import { SuiContext } from './context'
3
- import { ProcessResult } from './index'
3
+ import { ProcessResult } from '..'
4
4
  import Long from 'long'
5
5
 
6
6
  type IndexConfigure = {
@@ -40,8 +40,8 @@ export class SuiBaseProcessor {
40
40
  return this
41
41
  }
42
42
 
43
- public handleTransaction(txn: any): ProcessResult | null {
44
- const ctx = new SuiContext(this.address)
43
+ public handleTransaction(txn: any, slot: Long): ProcessResult | null {
44
+ const ctx = new SuiContext(this.address, slot)
45
45
 
46
46
  if (txn) {
47
47
  this.transactionHanlder(txn, ctx)
File without changes
package/src/error.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // Transform error in more readable format
2
- import { Context } from './context'
2
+ import { Context } from './core/context'
3
3
  import { errors } from 'ethers'
4
4
 
5
5
  export class EthersError extends Error {
package/src/index.ts CHANGED
@@ -1,23 +1,11 @@
1
- export { BaseProcessor } from './base-processor'
2
- export { GenericProcessor } from './generic-processor'
3
- export { BaseProcessorTemplate } from './base-processor-template'
4
- export { Context, ContractView, BoundContractView, SolanaContext } from './context'
5
1
  export { ProcessorServiceImpl } from './service'
6
- export { CounterBinding, Meter, GaugeBinding, Counter, Gauge, MetricDescriptorOption } from './meter'
7
2
  export { getProvider, setProvider, DummyProvider } from './provider'
8
- export { SolanaBaseProcessor } from './solana-processor'
9
- export { SuiBaseProcessor } from './sui-processor'
10
- export { AptosBaseProcessor } from './aptos-processor'
11
3
  export { ContractNamer } from './contract-namer'
12
- export { BindOptions, SolanaBindOptions, SuiBindOptions, AptosBindOptions } from './bind-options'
13
4
  export { transformEtherError } from './error'
14
5
  export { ProcessorState } from './processor-state'
15
- export { BigNumber as BigDecimal } from 'bignumber.js'
16
6
  export { EthersError } from './error'
17
- export type { TypedCallTrace } from './trace'
18
7
 
19
8
  export { getProcessor, addProcessor, getContractByABI, addContractByABI, getContractName } from './binds'
20
9
 
21
10
  export * from './gen/processor/protos/processor'
22
-
23
- export { SPLTokenProcessor } from './solana/builtin'
11
+ export * from './core'
@@ -1,12 +1,15 @@
1
- import { BaseProcessor } from './base-processor'
1
+ import {
2
+ BaseProcessor,
3
+ BoundContractView,
4
+ ContractView,
5
+ BaseProcessorTemplate,
6
+ SolanaBaseProcessor,
7
+ SuiBaseProcessor,
8
+ AptosBaseProcessor,
9
+ } from './core'
2
10
  import { BaseContract } from 'ethers'
3
- import { BoundContractView, ContractView } from './context'
4
- import { BaseProcessorTemplate } from './base-processor-template'
5
11
  import { TemplateInstance } from './gen/processor/protos/processor'
6
12
  import { Provider } from '@ethersproject/providers'
7
- import { SolanaBaseProcessor } from './solana-processor'
8
- import { SuiBaseProcessor } from './sui-processor'
9
- import { AptosBaseProcessor } from './aptos-processor'
10
13
 
11
14
  export class ProcessorState {
12
15
  // from abiName_address_chainId => contract wrapper