@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.
Files changed (126) 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/processor-state.d.ts +2 -0
  40. package/lib/processor-state.js +1 -0
  41. package/lib/processor-state.js.map +1 -1
  42. package/lib/service.js +47 -0
  43. package/lib/service.js.map +1 -1
  44. package/lib/solana/builtin/spl-token-processor.d.ts +16 -1
  45. package/lib/solana/builtin/spl-token-processor.js +120 -0
  46. package/lib/solana/builtin/spl-token-processor.js.map +1 -1
  47. package/lib/solana/builtin/types.d.ts +97 -0
  48. package/lib/solana/builtin/types.js.map +1 -1
  49. package/lib/test/{mirrorworld.d.ts → aptos.test.d.ts} +0 -0
  50. package/lib/test/aptos.test.js +142 -0
  51. package/lib/test/aptos.test.js.map +1 -0
  52. package/lib/test/erc20.js.map +1 -1
  53. package/lib/test/erc20.test.js.map +1 -1
  54. package/lib/test/solana.test.js +1 -17
  55. package/lib/test/solana.test.js.map +1 -1
  56. package/lib/test/souffl3.d.ts +1 -0
  57. package/lib/test/souffl3.js +24 -0
  58. package/lib/test/souffl3.js.map +1 -0
  59. package/lib/test/test-provider.d.ts +1 -1
  60. package/lib/test/test-provider.js +11 -5
  61. package/lib/test/test-provider.js.map +1 -1
  62. package/lib/test/types/{game_wallet.d.ts → basic_1.d.ts} +2 -21
  63. package/lib/test/types/basic_1.js +66 -0
  64. package/lib/test/types/basic_1.js.map +1 -0
  65. package/lib/test/types/basic_1_processor.d.ts +13 -0
  66. package/lib/test/types/basic_1_processor.js +41 -0
  67. package/lib/test/types/basic_1_processor.js.map +1 -0
  68. package/lib/utils/chainlink-oracles-goerli.csv +8 -0
  69. package/lib/utils/chainlink-oracles.csv +217 -0
  70. package/lib/utils/dex-price.d.ts +22 -0
  71. package/lib/utils/dex-price.js +114 -0
  72. package/lib/utils/dex-price.js.map +1 -0
  73. package/lib/utils/dex-price.test.d.ts +1 -0
  74. package/lib/utils/dex-price.test.js +22 -0
  75. package/lib/utils/dex-price.test.js.map +1 -0
  76. package/lib/utils/erc20.d.ts +1 -0
  77. package/lib/utils/erc20.js +7 -3
  78. package/lib/utils/erc20.js.map +1 -1
  79. package/lib/utils/index.d.ts +3 -1
  80. package/lib/utils/index.js +6 -1
  81. package/lib/utils/index.js.map +1 -1
  82. package/package.json +3 -3
  83. package/src/abis/EACAggregatorProxy.json +227 -0
  84. package/src/aptos-processor.ts +75 -0
  85. package/src/bind-options.ts +1 -0
  86. package/src/builtin/eacaggregatorproxy/index.ts +6 -0
  87. package/src/builtin/eacaggregatorproxy/test-utils.ts +89 -0
  88. package/src/builtin/internal/EACAggregatorProxy.ts +861 -0
  89. package/src/builtin/internal/eacaggregatorproxy_processor.ts +1417 -0
  90. package/src/builtin/internal/factories/EACAggregatorProxy__factory.ts +533 -0
  91. package/src/builtin/internal/factories/index.ts +1 -0
  92. package/src/builtin/internal/index.ts +2 -0
  93. package/src/context.ts +15 -2
  94. package/src/gen/processor/protos/processor.ts +20 -0
  95. package/src/index.ts +2 -1
  96. package/src/meter.ts +18 -2
  97. package/src/processor-state.ts +3 -0
  98. package/src/service.ts +51 -0
  99. package/src/solana/builtin/spl-token-processor.ts +137 -1
  100. package/src/solana/builtin/types.ts +11 -0
  101. package/src/test/abis/solana/basic_1.json +62 -0
  102. package/src/test/aptos.test.ts +148 -0
  103. package/src/test/erc20.test.ts +1 -1
  104. package/src/test/erc20.ts +0 -1
  105. package/src/test/solana.test.ts +1 -18
  106. package/src/test/souffl3.ts +24 -0
  107. package/src/test/test-provider.ts +11 -5
  108. package/src/test/types/basic_1.ts +62 -0
  109. package/src/test/types/basic_1_processor.ts +41 -0
  110. package/src/utils/chainlink-oracles-goerli.csv +8 -0
  111. package/src/utils/chainlink-oracles.csv +217 -0
  112. package/src/utils/dex-price.test.ts +24 -0
  113. package/src/utils/dex-price.ts +136 -0
  114. package/src/utils/erc20.ts +5 -1
  115. package/src/utils/index.ts +3 -1
  116. package/lib/test/mirrorworld.js +0 -42
  117. package/lib/test/mirrorworld.js.map +0 -1
  118. package/lib/test/types/game_wallet.js +0 -1396
  119. package/lib/test/types/game_wallet.js.map +0 -1
  120. package/lib/test/types/game_wallet_processor.d.ts +0 -107
  121. package/lib/test/types/game_wallet_processor.js +0 -105
  122. package/lib/test/types/game_wallet_processor.js.map +0 -1
  123. package/src/test/abis/solana/mirrorworld.json +0 -1392
  124. package/src/test/mirrorworld.ts +0 -40
  125. package/src/test/types/game_wallet.ts +0 -1392
  126. package/src/test/types/game_wallet_processor.ts +0 -113
@@ -1,113 +0,0 @@
1
- import { BorshInstructionCoder, Instruction, Idl, BN } from '@project-serum/anchor'
2
- import { SolanaBaseProcessor, SolanaContext, SolanaBindOptions } from "@sentio/sdk"
3
- import { game_wallet_idl } from "./game_wallet"
4
- import bs58 from 'bs58'
5
- import { PublicKey } from '@solana/web3.js'
6
-
7
- export class GameWalletProcessor extends SolanaBaseProcessor {
8
- static bind(options: SolanaBindOptions): GameWalletProcessor {
9
- if (options && !options.name) {
10
- options.name = 'GameWallet'
11
- }
12
- return new GameWalletProcessor(options)
13
- }
14
-
15
- decodeInstruction: (rawInstruction: string) => Instruction | null = (rawInstruction) => {
16
- const instructionCoder = new BorshInstructionCoder(game_wallet_idl as Idl)
17
- const decodedIns = instructionCoder.decode(Buffer.from(bs58.decode(rawInstruction)))
18
- return decodedIns
19
- }
20
-
21
-
22
- onInitializeTokenConfig(handler: (args: { tokenDecimal: number, isPaused: boolean, canDeposit: boolean, canWithdraw: boolean, canSpend: boolean, canDistribute: boolean, isWithdrawServiceFeeEnable: boolean, withdrawServiceFeePercentage: BN, isSpendServiceFeeEnable: boolean, spendServiceFeePercentage: BN, isDistributionServiceFeeEnable: boolean, distributionServiceFeePercentage: BN, isMinWithdrawEnable: boolean, isMaxWithdrawEnable: boolean, minWithdraw: BN, maxWithdraw: BN }, ctx: SolanaContext) => void): GameWalletProcessor {
23
- this.onInstruction('initializeTokenConfig', (ins: Instruction, ctx) => {
24
- if (ins) {
25
- handler(ins.data as { tokenDecimal: number, isPaused: boolean, canDeposit: boolean, canWithdraw: boolean, canSpend: boolean, canDistribute: boolean, isWithdrawServiceFeeEnable: boolean, withdrawServiceFeePercentage: BN, isSpendServiceFeeEnable: boolean, spendServiceFeePercentage: BN, isDistributionServiceFeeEnable: boolean, distributionServiceFeePercentage: BN, isMinWithdrawEnable: boolean, isMaxWithdrawEnable: boolean, minWithdraw: BN, maxWithdraw: BN }, ctx)
26
- }
27
- })
28
- return this
29
- }
30
-
31
- onDeposit(handler: (args: { tokenConfigBump: number, depositPoolBump: number, depositPoolTokenAccountBump: number, amount: BN }, ctx: SolanaContext) => void): GameWalletProcessor {
32
- this.onInstruction('deposit', (ins: Instruction, ctx) => {
33
- if (ins) {
34
- handler(ins.data as { tokenConfigBump: number, depositPoolBump: number, depositPoolTokenAccountBump: number, amount: BN }, ctx)
35
- }
36
- })
37
- return this
38
- }
39
-
40
- onWithdraw(handler: (args: { tokenConfigBump: number, depositPoolBump: number, depositPoolTokenAccountBump: number, userTokenConfigBump: number, amount: BN, nonce: BN }, ctx: SolanaContext) => void): GameWalletProcessor {
41
- this.onInstruction('withdraw', (ins: Instruction, ctx) => {
42
- if (ins) {
43
- handler(ins.data as { tokenConfigBump: number, depositPoolBump: number, depositPoolTokenAccountBump: number, userTokenConfigBump: number, amount: BN, nonce: BN }, ctx)
44
- }
45
- })
46
- return this
47
- }
48
-
49
- onSpend(handler: (args: { tokenConfigBump: number, depositPoolBump: number, depositPoolTokenAccountBump: number, userTokenConfigBump: number, amount: BN, nonce: BN }, ctx: SolanaContext) => void): GameWalletProcessor {
50
- this.onInstruction('spend', (ins: Instruction, ctx) => {
51
- if (ins) {
52
- handler(ins.data as { tokenConfigBump: number, depositPoolBump: number, depositPoolTokenAccountBump: number, userTokenConfigBump: number, amount: BN, nonce: BN }, ctx)
53
- }
54
- })
55
- return this
56
- }
57
-
58
- onSpendWithoutUser(handler: (args: { tokenConfigBump: number, depositPoolBump: number, depositPoolTokenAccountBump: number, userTokenConfigBump: number, amount: BN, nonce: BN }, ctx: SolanaContext) => void): GameWalletProcessor {
59
- this.onInstruction('spendWithoutUser', (ins: Instruction, ctx) => {
60
- if (ins) {
61
- handler(ins.data as { tokenConfigBump: number, depositPoolBump: number, depositPoolTokenAccountBump: number, userTokenConfigBump: number, amount: BN, nonce: BN }, ctx)
62
- }
63
- })
64
- return this
65
- }
66
-
67
- onAddDistributeSupply(handler: (args: { tokenConfigBump: number, distributionPoolBump: number, distributionPoolTokenAccountBump: number, amount: BN }, ctx: SolanaContext) => void): GameWalletProcessor {
68
- this.onInstruction('addDistributeSupply', (ins: Instruction, ctx) => {
69
- if (ins) {
70
- handler(ins.data as { tokenConfigBump: number, distributionPoolBump: number, distributionPoolTokenAccountBump: number, amount: BN }, ctx)
71
- }
72
- })
73
- return this
74
- }
75
-
76
- onDistribute(handler: (args: { tokenConfigBump: number, depositPoolBump: number, depositPoolTokenAccountBump: number, distributionPoolBump: number, distributionPoolTokenAccountBump: number, amount: BN, nonce: BN }, ctx: SolanaContext) => void): GameWalletProcessor {
77
- this.onInstruction('distribute', (ins: Instruction, ctx) => {
78
- if (ins) {
79
- handler(ins.data as { tokenConfigBump: number, depositPoolBump: number, depositPoolTokenAccountBump: number, distributionPoolBump: number, distributionPoolTokenAccountBump: number, amount: BN, nonce: BN }, ctx)
80
- }
81
- })
82
- return this
83
- }
84
-
85
- onDistributeWithoutUser(handler: (args: { tokenConfigBump: number, depositPoolBump: number, depositPoolTokenAccountBump: number, distributionPoolBump: number, distributionPoolTokenAccountBump: number, amount: BN, nonce: BN }, ctx: SolanaContext) => void): GameWalletProcessor {
86
- this.onInstruction('distributeWithoutUser', (ins: Instruction, ctx) => {
87
- if (ins) {
88
- handler(ins.data as { tokenConfigBump: number, depositPoolBump: number, depositPoolTokenAccountBump: number, distributionPoolBump: number, distributionPoolTokenAccountBump: number, amount: BN, nonce: BN }, ctx)
89
- }
90
- })
91
- return this
92
- }
93
-
94
- onUpdateTokenConfig(handler: (args: { tokenConfigBump: number, tokenDecimal: number, isPaused: boolean, canDeposit: boolean, canWithdraw: boolean, canSpend: boolean, canDistribute: boolean, isWithdrawServiceFeeEnable: boolean, withdrawServiceFeePercentage: BN, isSpendServiceFeeEnable: boolean, spendServiceFeePercentage: BN, isDistributionServiceFeeEnable: boolean, distributionServiceFeePercentage: BN, isMinWithdrawEnable: boolean, isMaxWithdrawEnable: boolean, minWithdraw: BN, maxWithdraw: BN }, ctx: SolanaContext) => void): GameWalletProcessor {
95
- this.onInstruction('updateTokenConfig', (ins: Instruction, ctx) => {
96
- if (ins) {
97
- handler(ins.data as { tokenConfigBump: number, tokenDecimal: number, isPaused: boolean, canDeposit: boolean, canWithdraw: boolean, canSpend: boolean, canDistribute: boolean, isWithdrawServiceFeeEnable: boolean, withdrawServiceFeePercentage: BN, isSpendServiceFeeEnable: boolean, spendServiceFeePercentage: BN, isDistributionServiceFeeEnable: boolean, distributionServiceFeePercentage: BN, isMinWithdrawEnable: boolean, isMaxWithdrawEnable: boolean, minWithdraw: BN, maxWithdraw: BN }, ctx)
98
- }
99
- })
100
- return this
101
- }
102
-
103
- onUpdateUserTokenConfig(handler: (args: { tokenConfigBump: number, userTokenConfigBump: number, isActive: boolean, canDeposit: boolean, canWithdraw: boolean, canSpend: boolean, canDistribute: boolean }, ctx: SolanaContext) => void): GameWalletProcessor {
104
- this.onInstruction('updateUserTokenConfig', (ins: Instruction, ctx) => {
105
- if (ins) {
106
- handler(ins.data as { tokenConfigBump: number, userTokenConfigBump: number, isActive: boolean, canDeposit: boolean, canWithdraw: boolean, canSpend: boolean, canDistribute: boolean }, ctx)
107
- }
108
- })
109
- return this
110
- }
111
-
112
- }
113
-