@sentio/sdk 1.16.3 → 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.
Files changed (149) hide show
  1. package/lib/aptos-processor.d.ts +21 -0
  2. package/lib/aptos-processor.js +65 -0
  3. package/lib/aptos-processor.js.map +1 -0
  4. package/lib/bind-options.d.ts +2 -0
  5. package/lib/bind-options.js +4 -1
  6. package/lib/bind-options.js.map +1 -1
  7. package/lib/builtin/eacaggregatorproxy/index.d.ts +2 -0
  8. package/lib/builtin/eacaggregatorproxy/index.js +22 -0
  9. package/lib/builtin/eacaggregatorproxy/index.js.map +1 -0
  10. package/lib/builtin/eacaggregatorproxy/test-utils.d.ts +6 -0
  11. package/lib/builtin/eacaggregatorproxy/test-utils.js +57 -0
  12. package/lib/builtin/eacaggregatorproxy/test-utils.js.map +1 -0
  13. package/lib/builtin/internal/EACAggregatorProxy.d.ts +460 -0
  14. package/lib/builtin/internal/EACAggregatorProxy.js +3 -0
  15. package/lib/builtin/internal/EACAggregatorProxy.js.map +1 -0
  16. package/lib/builtin/internal/eacaggregatorproxy_processor.d.ts +317 -0
  17. package/lib/builtin/internal/eacaggregatorproxy_processor.js +813 -0
  18. package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +1 -0
  19. package/lib/builtin/internal/factories/EACAggregatorProxy__factory.d.ts +46 -0
  20. package/lib/builtin/internal/factories/EACAggregatorProxy__factory.js +527 -0
  21. package/lib/builtin/internal/factories/EACAggregatorProxy__factory.js.map +1 -0
  22. package/lib/builtin/internal/factories/index.d.ts +1 -0
  23. package/lib/builtin/internal/factories/index.js +3 -1
  24. package/lib/builtin/internal/factories/index.js.map +1 -1
  25. package/lib/builtin/internal/index.d.ts +2 -0
  26. package/lib/builtin/internal/index.js +3 -1
  27. package/lib/builtin/internal/index.js.map +1 -1
  28. package/lib/context.d.ts +5 -0
  29. package/lib/context.js +15 -3
  30. package/lib/context.js.map +1 -1
  31. package/lib/gen/processor/protos/processor.d.ts +2 -0
  32. package/lib/gen/processor/protos/processor.js +19 -0
  33. package/lib/gen/processor/protos/processor.js.map +1 -1
  34. package/lib/index.d.ts +2 -1
  35. package/lib/index.js +4 -1
  36. package/lib/index.js.map +1 -1
  37. package/lib/meter.js +17 -0
  38. package/lib/meter.js.map +1 -1
  39. package/lib/numberish.js +7 -0
  40. package/lib/numberish.js.map +1 -1
  41. package/lib/processor-state.d.ts +2 -0
  42. package/lib/processor-state.js +1 -0
  43. package/lib/processor-state.js.map +1 -1
  44. package/lib/service.js +47 -0
  45. package/lib/service.js.map +1 -1
  46. package/lib/solana/builtin/spl-token-processor.d.ts +16 -1
  47. package/lib/solana/builtin/spl-token-processor.js +120 -0
  48. package/lib/solana/builtin/spl-token-processor.js.map +1 -1
  49. package/lib/solana/builtin/types.d.ts +97 -0
  50. package/lib/solana/builtin/types.js.map +1 -1
  51. package/lib/test/{mirrorworld.d.ts → aptos.test.d.ts} +0 -0
  52. package/lib/test/aptos.test.js +142 -0
  53. package/lib/test/aptos.test.js.map +1 -0
  54. package/lib/test/erc20-template.test.js +21 -2
  55. package/lib/test/erc20-template.test.js.map +1 -1
  56. package/lib/test/erc20.js +4 -5
  57. package/lib/test/erc20.js.map +1 -1
  58. package/lib/test/erc20.test.js +0 -13
  59. package/lib/test/erc20.test.js.map +1 -1
  60. package/lib/test/{tic-tac-toe.d.ts → error-capture.test.d.ts} +0 -0
  61. package/lib/test/error-capture.test.js +76 -0
  62. package/lib/test/error-capture.test.js.map +1 -0
  63. package/lib/test/solana.test.js +1 -17
  64. package/lib/test/solana.test.js.map +1 -1
  65. package/lib/test/souffl3.d.ts +1 -0
  66. package/lib/test/souffl3.js +24 -0
  67. package/lib/test/souffl3.js.map +1 -0
  68. package/lib/test/sui.test.js +28 -1
  69. package/lib/test/sui.test.js.map +1 -1
  70. package/lib/test/test-provider.d.ts +1 -1
  71. package/lib/test/test-provider.js +11 -5
  72. package/lib/test/test-provider.js.map +1 -1
  73. package/lib/test/types/{game_wallet.d.ts → basic_1.d.ts} +2 -21
  74. package/lib/test/types/basic_1.js +66 -0
  75. package/lib/test/types/basic_1.js.map +1 -0
  76. package/lib/test/types/basic_1_processor.d.ts +13 -0
  77. package/lib/test/types/basic_1_processor.js +41 -0
  78. package/lib/test/types/basic_1_processor.js.map +1 -0
  79. package/lib/utils/chainlink-oracles-goerli.csv +8 -0
  80. package/lib/utils/chainlink-oracles.csv +217 -0
  81. package/lib/utils/dex-price.d.ts +22 -0
  82. package/lib/utils/dex-price.js +114 -0
  83. package/lib/utils/dex-price.js.map +1 -0
  84. package/lib/utils/dex-price.test.d.ts +1 -0
  85. package/lib/utils/dex-price.test.js +22 -0
  86. package/lib/utils/dex-price.test.js.map +1 -0
  87. package/lib/utils/erc20.d.ts +1 -0
  88. package/lib/utils/erc20.js +7 -3
  89. package/lib/utils/erc20.js.map +1 -1
  90. package/lib/utils/index.d.ts +3 -1
  91. package/lib/utils/index.js +6 -1
  92. package/lib/utils/index.js.map +1 -1
  93. package/package.json +3 -3
  94. package/src/abis/EACAggregatorProxy.json +227 -0
  95. package/src/aptos-processor.ts +75 -0
  96. package/src/bind-options.ts +1 -0
  97. package/src/builtin/eacaggregatorproxy/index.ts +6 -0
  98. package/src/builtin/eacaggregatorproxy/test-utils.ts +89 -0
  99. package/src/builtin/internal/EACAggregatorProxy.ts +861 -0
  100. package/src/builtin/internal/eacaggregatorproxy_processor.ts +1417 -0
  101. package/src/builtin/internal/factories/EACAggregatorProxy__factory.ts +533 -0
  102. package/src/builtin/internal/factories/index.ts +1 -0
  103. package/src/builtin/internal/index.ts +2 -0
  104. package/src/context.ts +15 -2
  105. package/src/gen/processor/protos/processor.ts +20 -0
  106. package/src/index.ts +2 -1
  107. package/src/meter.ts +18 -2
  108. package/src/numberish.ts +7 -0
  109. package/src/processor-state.ts +3 -0
  110. package/src/service.ts +51 -0
  111. package/src/solana/builtin/spl-token-processor.ts +137 -1
  112. package/src/solana/builtin/types.ts +11 -0
  113. package/src/test/abis/solana/basic_1.json +62 -0
  114. package/src/test/aptos.test.ts +148 -0
  115. package/src/test/erc20-template.test.ts +26 -3
  116. package/src/test/erc20.test.ts +1 -15
  117. package/src/test/erc20.ts +4 -5
  118. package/src/test/error-capture.test.ts +82 -0
  119. package/src/test/solana.test.ts +1 -18
  120. package/src/test/souffl3.ts +24 -0
  121. package/src/test/sui.test.ts +31 -2
  122. package/src/test/test-provider.ts +11 -5
  123. package/src/test/types/basic_1.ts +62 -0
  124. package/src/test/types/basic_1_processor.ts +41 -0
  125. package/src/utils/chainlink-oracles-goerli.csv +8 -0
  126. package/src/utils/chainlink-oracles.csv +217 -0
  127. package/src/utils/dex-price.test.ts +24 -0
  128. package/src/utils/dex-price.ts +136 -0
  129. package/src/utils/erc20.ts +5 -1
  130. package/src/utils/index.ts +3 -1
  131. package/lib/test/erc20-template.d.ts +0 -1
  132. package/lib/test/erc20-template.js +0 -23
  133. package/lib/test/erc20-template.js.map +0 -1
  134. package/lib/test/mirrorworld.js +0 -42
  135. package/lib/test/mirrorworld.js.map +0 -1
  136. package/lib/test/tic-tac-toe.js +0 -31
  137. package/lib/test/tic-tac-toe.js.map +0 -1
  138. package/lib/test/types/game_wallet.js +0 -1396
  139. package/lib/test/types/game_wallet.js.map +0 -1
  140. package/lib/test/types/game_wallet_processor.d.ts +0 -107
  141. package/lib/test/types/game_wallet_processor.js +0 -105
  142. package/lib/test/types/game_wallet_processor.js.map +0 -1
  143. package/src/test/abis/solana/mirrorworld.json +0 -1392
  144. package/src/test/erc20-template.ts +0 -25
  145. package/src/test/mirrorworld.ts +0 -40
  146. package/src/test/sentio.yaml +0 -4
  147. package/src/test/tic-tac-toe.ts +0 -31
  148. package/src/test/types/game_wallet.ts +0 -1392
  149. package/src/test/types/game_wallet_processor.ts +0 -113
@@ -0,0 +1,136 @@
1
+ import { getEACAggregatorProxyContract } from '../builtin/internal/eacaggregatorproxy_processor'
2
+ import path from 'path'
3
+ import fs from 'fs'
4
+
5
+ import { parse } from 'csv-parse/sync'
6
+ import { BlockTag } from '@ethersproject/providers'
7
+ import { scaleDown } from './erc20'
8
+
9
+ type OralceRecord = {
10
+ Pair: string
11
+ Asset: string
12
+ Type: string
13
+ Address: string
14
+ }
15
+
16
+ export enum PriceUnit {
17
+ USD = 0,
18
+ ETH = 1,
19
+ BTC = 2,
20
+ }
21
+
22
+ export interface DexPriceResult {
23
+ price?: number
24
+ error?: string
25
+ }
26
+
27
+ // Load price feed from https://docs.chain.link/docs/data-feeds/price-feeds/addresses/?network=ethereum
28
+ // and then use EACAggregatorProxy contract to get price
29
+ class DexPrice {
30
+ private USD_ORACLE_MAP = new Map<string, string>()
31
+ private ETH_ORACLE_MAP = new Map<string, string>()
32
+ private BTC_ORACLE_MAP = new Map<string, string>()
33
+ private ASSETS_INFOS = new Map<string, number>()
34
+
35
+ private readonly chainId: number
36
+
37
+ constructor(csvFileName: string, chainId: number) {
38
+ this.chainId = chainId
39
+ const csvFilePath = path.resolve(__dirname, csvFileName)
40
+ const fileContent = fs.readFileSync(csvFilePath, { encoding: 'utf-8' })
41
+ const headers = ['Pair', 'Asset', 'Type', 'Address']
42
+
43
+ const records: OralceRecord[] = parse(fileContent, {
44
+ delimiter: ',',
45
+ columns: headers,
46
+ skip_empty_lines: true,
47
+ })
48
+
49
+ for (const record of records) {
50
+ const pair = record.Pair.split('/')
51
+ const asset = pair[0].trim().toLowerCase()
52
+ const target = pair[1].trim().toLowerCase()
53
+ const address = record.Address.toLowerCase()
54
+ if (target === 'usd') {
55
+ this.USD_ORACLE_MAP.set(asset, address)
56
+ } else if (target === 'eth') {
57
+ this.ETH_ORACLE_MAP.set(asset, address)
58
+ } else if (target == 'btc') {
59
+ this.BTC_ORACLE_MAP.set(asset, address)
60
+ } else {
61
+ console.error('wrong asset record:' + JSON.stringify(record))
62
+ }
63
+
64
+ // console.log(asset, target, address)
65
+ }
66
+ }
67
+
68
+ // asset: symbol of the asset
69
+ // unit: usd, eth or btc
70
+ // blockTag: blockNumber of block symbol like "latest"
71
+ // returns the asset price,
72
+ // throw exception if calling to price feed failed, e.g. due to a invalid block number
73
+ async getPrice(
74
+ asset: string,
75
+ blockTag: BlockTag = 'latest',
76
+ unit: PriceUnit = PriceUnit.USD
77
+ ): Promise<DexPriceResult> {
78
+ // if (chainId !== 1 && chainId !== 5) {
79
+ // return {
80
+ // error: "current dex price only support chain 1 (mainnet) or 5 (goerli)"
81
+ // }
82
+ // }
83
+
84
+ let oracleMap = this.USD_ORACLE_MAP
85
+ switch (unit) {
86
+ case PriceUnit.ETH:
87
+ oracleMap = this.ETH_ORACLE_MAP
88
+ break
89
+ case PriceUnit.BTC:
90
+ oracleMap = this.BTC_ORACLE_MAP
91
+ break
92
+ default:
93
+ }
94
+
95
+ asset = asset.trim().toLowerCase()
96
+
97
+ const addr = oracleMap.get(asset)
98
+ if (!addr) {
99
+ return {
100
+ error: 'No price feed found for asset',
101
+ }
102
+ }
103
+
104
+ const contract = getEACAggregatorProxyContract(addr, this.chainId)
105
+ try {
106
+ const price = await contract.latestAnswer({
107
+ blockTag: blockTag,
108
+ })
109
+
110
+ let decimal = this.ASSETS_INFOS.get(asset)
111
+ if (!decimal) {
112
+ decimal = await contract.decimals()
113
+ this.ASSETS_INFOS.set(asset, decimal)
114
+ }
115
+
116
+ return {
117
+ price: scaleDown(price, decimal).toNumber(),
118
+ }
119
+ } catch (e) {
120
+ return {
121
+ error:
122
+ 'Price query error for ' +
123
+ asset +
124
+ ' failed at ' +
125
+ addr +
126
+ ' at chain ' +
127
+ this.chainId +
128
+ '. Details: ' +
129
+ e.toString(),
130
+ }
131
+ }
132
+ }
133
+ }
134
+
135
+ export const EthereumDexPrice = new DexPrice('chainlink-oracles.csv', 1)
136
+ export const GoerliDexPrice = new DexPrice('chainlink-oracles-goerli.csv', 5)
@@ -61,6 +61,10 @@ export async function getER20NormalizedAmount(
61
61
  chainId: number
62
62
  ): Promise<BigDecimal> {
63
63
  const tokenInfo = await getERC20TokenInfo(tokenAddress, chainId)
64
- const divider = new BigDecimal(10).pow(tokenInfo.decimal)
64
+ return scaleDown(amount, tokenInfo.decimal)
65
+ }
66
+
67
+ export function scaleDown(amount: BigNumber, decimal: number) {
68
+ const divider = new BigDecimal(10).pow(decimal)
65
69
  return toBigDecimal(amount).dividedBy(divider)
66
70
  }
@@ -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'
@@ -1 +0,0 @@
1
- export declare const filter: import("../builtin/erc20").TransferEventFilter;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filter = void 0;
4
- const erc20_1 = require("../builtin/erc20");
5
- exports.filter = erc20_1.ERC20Processor.filters.Transfer('0x0000000000000000000000000000000000000000', '0xb329e39ebefd16f40d38f07643652ce17ca5bac1');
6
- const processorTemplate = new erc20_1.ERC20ProcessorTemplate().onEventTransfer(async function (event, ctx) {
7
- console.log('');
8
- });
9
- erc20_1.ERC20Processor.bind({
10
- address: '0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9',
11
- network: 1,
12
- name: 'x2y2',
13
- startBlock: 14201940,
14
- }).onEventTransfer(async function (event, ctx) {
15
- processorTemplate.bind({
16
- address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
17
- network: 3,
18
- name: 'dynamic',
19
- });
20
- // template.bind('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 3, 'dynamic')
21
- ctx.meter.Counter('c1').add(1);
22
- }, exports.filter);
23
- //# sourceMappingURL=erc20-template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"erc20-template.js","sourceRoot":"","sources":["../../src/test/erc20-template.ts"],"names":[],"mappings":";;;AAAA,4CAAyE;AAE5D,QAAA,MAAM,GAAG,sBAAc,CAAC,OAAO,CAAC,QAAQ,CACnD,4CAA4C,EAC5C,4CAA4C,CAC7C,CAAA;AAED,MAAM,iBAAiB,GAAG,IAAI,8BAAsB,EAAE,CAAC,eAAe,CAAC,KAAK,WAAW,KAAK,EAAE,GAAG;IAC/F,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA;AAEF,sBAAc,CAAC,IAAI,CAAC;IAClB,OAAO,EAAE,4CAA4C;IACrD,OAAO,EAAE,CAAC;IACV,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,QAAQ;CACrB,CAAC,CAAC,eAAe,CAAC,KAAK,WAAW,KAAK,EAAE,GAAG;IAC3C,iBAAiB,CAAC,IAAI,CAAC;QACrB,OAAO,EAAE,4CAA4C;QACrD,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,SAAS;KAChB,CAAC,CAAA;IACF,4EAA4E;IAC5E,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAChC,CAAC,EAAE,cAAM,CAAC,CAAA","sourcesContent":["import { ERC20Processor, ERC20ProcessorTemplate } from '../builtin/erc20'\n\nexport const filter = ERC20Processor.filters.Transfer(\n '0x0000000000000000000000000000000000000000',\n '0xb329e39ebefd16f40d38f07643652ce17ca5bac1'\n)\n\nconst processorTemplate = new ERC20ProcessorTemplate().onEventTransfer(async function (event, ctx) {\n console.log('')\n})\n\nERC20Processor.bind({\n address: '0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9',\n network: 1,\n name: 'x2y2',\n startBlock: 14201940,\n}).onEventTransfer(async function (event, ctx) {\n processorTemplate.bind({\n address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n network: 3,\n name: 'dynamic',\n })\n // template.bind('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 3, 'dynamic')\n ctx.meter.Counter('c1').add(1)\n}, filter)\n"]}
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const game_wallet_processor_1 = require("./types/game_wallet_processor");
4
- game_wallet_processor_1.GameWalletProcessor.bind({ address: 'F78NhTC9XmP1DKsCBRz5LGdQc4n4yFbj2dURiv7T9gGZ' })
5
- .onDistributeWithoutUser((payload, ctx) => {
6
- const amount = payload.amount.toNumber();
7
- ctx.meter.Counter('deposit_pool_total_value').add(amount);
8
- ctx.meter.Counter('deposit_pool_current_value').add(amount);
9
- ctx.meter.Counter('distribution_pool_total_value').sub(amount);
10
- })
11
- .onDeposit((payload, ctx) => {
12
- const amount = payload.amount.toNumber();
13
- ctx.meter.Counter('deposit_pool_total_value').add(amount);
14
- ctx.meter.Counter('deposit_pool_current_value').add(amount);
15
- })
16
- .onWithdraw((payload, ctx) => {
17
- const amount = payload.amount.toNumber();
18
- ctx.meter.Counter('deposit_pool_total_value').add(amount);
19
- ctx.meter.Counter('distribution_pool_total_value').sub(amount);
20
- })
21
- .onSpend((payload, ctx) => {
22
- const amount = payload.amount.toNumber();
23
- ctx.meter.Counter('deposit_pool_total_value').add(amount);
24
- ctx.meter.Counter('distribution_pool_total_value').sub(amount);
25
- })
26
- .onDistribute((payload, ctx) => {
27
- const amount = payload.amount.toNumber();
28
- ctx.meter.Counter('deposit_pool_total_value').add(amount);
29
- ctx.meter.Counter('deposit_pool_current_value').add(amount);
30
- ctx.meter.Counter('distribution_pool_total_value').sub(amount);
31
- })
32
- .onSpendWithoutUser((payload, ctx) => {
33
- const amount = payload.amount.toNumber();
34
- ctx.meter.Counter('deposit_pool_total_value').add(amount);
35
- ctx.meter.Counter('deposit_pool_current_value').sub(amount);
36
- })
37
- .onAddDistributeSupply((payload, ctx) => {
38
- const amount = payload.amount.toNumber();
39
- ctx.meter.Counter('distribution_pool_total_value').add(amount);
40
- })
41
- .startSlot(142700000);
42
- //# sourceMappingURL=mirrorworld.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mirrorworld.js","sourceRoot":"","sources":["../../src/test/mirrorworld.ts"],"names":[],"mappings":"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","sourcesContent":["import { GameWalletProcessor } from './types/game_wallet_processor'\n\nGameWalletProcessor.bind({ address: 'F78NhTC9XmP1DKsCBRz5LGdQc4n4yFbj2dURiv7T9gGZ' })\n .onDistributeWithoutUser((payload, ctx) => {\n const amount = payload.amount.toNumber()\n ctx.meter.Counter('deposit_pool_total_value').add(amount)\n ctx.meter.Counter('deposit_pool_current_value').add(amount)\n ctx.meter.Counter('distribution_pool_total_value').sub(amount)\n })\n .onDeposit((payload, ctx) => {\n const amount = payload.amount.toNumber()\n ctx.meter.Counter('deposit_pool_total_value').add(amount)\n ctx.meter.Counter('deposit_pool_current_value').add(amount)\n })\n .onWithdraw((payload, ctx) => {\n const amount = payload.amount.toNumber()\n ctx.meter.Counter('deposit_pool_total_value').add(amount)\n ctx.meter.Counter('distribution_pool_total_value').sub(amount)\n })\n .onSpend((payload, ctx) => {\n const amount = payload.amount.toNumber()\n ctx.meter.Counter('deposit_pool_total_value').add(amount)\n ctx.meter.Counter('distribution_pool_total_value').sub(amount)\n })\n .onDistribute((payload, ctx) => {\n const amount = payload.amount.toNumber()\n ctx.meter.Counter('deposit_pool_total_value').add(amount)\n ctx.meter.Counter('deposit_pool_current_value').add(amount)\n ctx.meter.Counter('distribution_pool_total_value').sub(amount)\n })\n .onSpendWithoutUser((payload, ctx) => {\n const amount = payload.amount.toNumber()\n ctx.meter.Counter('deposit_pool_total_value').add(amount)\n ctx.meter.Counter('deposit_pool_current_value').sub(amount)\n })\n .onAddDistributeSupply((payload, ctx) => {\n const amount = payload.amount.toNumber()\n ctx.meter.Counter('distribution_pool_total_value').add(amount)\n })\n .startSlot(142700000)\n"]}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const sui_processor_1 = require("../sui-processor");
4
- class TicTacToeProcessor extends sui_processor_1.SuiBaseProcessor {
5
- static bind(options) {
6
- if (options && !options.name) {
7
- options.name = 'TicTacToe';
8
- }
9
- return new TicTacToeProcessor(options);
10
- }
11
- }
12
- TicTacToeProcessor.bind({
13
- startBlock: 0,
14
- address: '',
15
- }).onTransaction((txn, ctx) => {
16
- if (txn.certificate.data.transactions && txn.certificate.data.transactions.length > 0) {
17
- if (txn.certificate.data.transactions[0].Call.package.objectId === '0xb8252513f0b9efaa3e260842c4b84d8ff933522d') {
18
- if (txn.effects.events) {
19
- txn.effects.events.forEach((event) => {
20
- if (event.newObject) {
21
- const owner = event.newObject.recipient.AddressOwner;
22
- if (owner.toString().includes('0x1c27')) {
23
- ctx.meter.Counter('win_count').add(1);
24
- }
25
- }
26
- });
27
- }
28
- }
29
- }
30
- });
31
- //# sourceMappingURL=tic-tac-toe.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tic-tac-toe.js","sourceRoot":"","sources":["../../src/test/tic-tac-toe.ts"],"names":[],"mappings":";;AACA,oDAAmD;AAEnD,MAAM,kBAAmB,SAAQ,gCAAgB;IAC/C,MAAM,CAAC,IAAI,CAAC,OAAuB;QACjC,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YAC5B,OAAO,CAAC,IAAI,GAAG,WAAW,CAAA;SAC3B;QACD,OAAO,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAA;IACxC,CAAC;CACF;AAED,kBAAkB,CAAC,IAAI,CAAC;IACtB,UAAU,EAAE,CAAC;IACb,OAAO,EAAE,EAAE;CACZ,CAAC,CAAC,aAAa,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IAC5B,IAAI,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,IAAI,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;QACrF,IAAI,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,4CAA4C,EAAE;YAC/G,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE;gBACtB,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAA0D,EAAE,EAAE;oBACxF,IAAI,KAAK,CAAC,SAAS,EAAE;wBACnB,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,YAAY,CAAA;wBACpD,IAAK,KAAK,CAAC,QAAQ,EAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;4BACnD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;yBACtC;qBACF;gBACH,CAAC,CAAC,CAAA;aACH;SACF;KACF;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { SuiBindOptions } from '../bind-options'\nimport { SuiBaseProcessor } from '../sui-processor'\n\nclass TicTacToeProcessor extends SuiBaseProcessor {\n static bind(options: SuiBindOptions): TicTacToeProcessor {\n if (options && !options.name) {\n options.name = 'TicTacToe'\n }\n return new TicTacToeProcessor(options)\n }\n}\n\nTicTacToeProcessor.bind({\n startBlock: 0,\n address: '',\n}).onTransaction((txn, ctx) => {\n if (txn.certificate.data.transactions && txn.certificate.data.transactions.length > 0) {\n if (txn.certificate.data.transactions[0].Call.package.objectId === '0xb8252513f0b9efaa3e260842c4b84d8ff933522d') {\n if (txn.effects.events) {\n txn.effects.events.forEach((event: { newObject: { recipient: { AddressOwner: any } } }) => {\n if (event.newObject) {\n const owner = event.newObject.recipient.AddressOwner\n if ((owner.toString() as string).includes('0x1c27')) {\n ctx.meter.Counter('win_count').add(1)\n }\n }\n })\n }\n }\n }\n})\n"]}