Skip to content

Commit

Permalink
fix(sui): object chnage handler regression
Browse files Browse the repository at this point in the history
  • Loading branch information
zfy0701 committed Dec 17, 2024
1 parent c979a0b commit a0cfc92
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 29,440 deletions.
1 change: 1 addition & 0 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"./aptos/builtin": "./lib/aptos/builtin/index.js",
"./aptos/builtin/0x1": "./lib/aptos/builtin/0x1.js",
"./aptos/builtin/0x3": "./lib/aptos/builtin/0x3.js",
"./aptos/builtin/0x4": "./lib/aptos/builtin/0x4.js",
"./solana": "./lib/solana/index.js",
"./solana/builtin": "./lib/solana/builtin/index.js",
"./solana/codegen": "./lib/solana/codegen/index.js",
Expand Down
24,179 changes: 0 additions & 24,179 deletions packages/sdk/src/aptos/abis/0x1.json

This file was deleted.

3,086 changes: 0 additions & 3,086 deletions packages/sdk/src/aptos/abis/0x3.json

This file was deleted.

2,155 changes: 0 additions & 2,155 deletions packages/sdk/src/aptos/abis/0x4.json

This file was deleted.

19 changes: 10 additions & 9 deletions packages/sdk/src/sui/sui-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,18 @@ export class SuiPlugin extends Plugin {
chainId: processor.getChainId(),
startBlock: processor.config.startCheckpoint // TODO maybe use another field
})
for (const handler of processor.objectHandlers) {
const handlerId = handlers.suiObjectHandlers.push(handler.handler) - 1

for (const handler of processor.objectChangeHandlers) {
const handlerId = handlers.suiObjectChangeHandlers.push(handler.handler) - 1
const objectChangeHandler: MoveResourceChangeConfig = {
type: handler.type,
handlerId
}
accountConfig.moveResourceChangeConfigs.push(objectChangeHandler)
for (const handler of processor.objectChangeHandlers) {
const handlerId = handlers.suiObjectChangeHandlers.push(handler.handler) - 1
const objectChangeHandler: MoveResourceChangeConfig = {
type: handler.type,
handlerId
}
accountConfig.moveResourceChangeConfigs.push(objectChangeHandler)
}

for (const handler of processor.objectHandlers) {
const handlerId = handlers.suiObjectHandlers.push(handler.handler) - 1

accountConfig.moveIntervalConfigs.push({
intervalConfig: {
Expand Down
26 changes: 15 additions & 11 deletions packages/sdk/src/sui/tests/sui.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,31 @@ describe('Test Sui Example', () => {
ctx.meter.Gauge('size').record(objects.length)
})

SuiObjectTypeProcessor.bind({ objectType: validator.Validator.type() }).onTimeInterval(
(self, objects, ctx) => {
ctx.meter
.Gauge('validator')
.record(self.data_decoded.voting_power, { address: self.data_decoded.metadata.primary_address })
},
60,
60,
{ owned: false }
)
SuiObjectTypeProcessor.bind({ objectType: validator.Validator.type() })
.onTimeInterval(
(self, objects, ctx) => {
ctx.meter
.Gauge('validator')
.record(self.data_decoded.voting_power, { address: self.data_decoded.metadata.primary_address })
},
60,
60,
{ owned: false }
)
.onObjectChange((self, ctx) => {})
})

before(async () => {
await service.start({ templateInstances: [] })
})

test('check configuration ', async () => {
test('check configuration', async () => {
const config = await service.getConfig({})
expect(config.contractConfigs).length(2)
expect(config.accountConfigs).length(2)
expect(config.accountConfigs[0].moveIntervalConfigs[0].ownerType).eq(MoveOwnerType.OBJECT)
expect(config.accountConfigs[1].moveIntervalConfigs[0].ownerType).eq(MoveOwnerType.TYPE)
expect(config.accountConfigs[1].moveResourceChangeConfigs[0].type).eq(validator.Validator.type().qname)
})

test('Check event dispatch', async () => {
Expand Down

0 comments on commit a0cfc92

Please sign in to comment.