Skip to content

Commit

Permalink
fix(aptos): ignore error get pair metadata for some token. move now f…
Browse files Browse the repository at this point in the history
…etch all inputs and events by default (#1147)
  • Loading branch information
zfy0701 authored Feb 2, 2025
1 parent ce1778e commit 3acfd62
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/sdk/src/aptos/aptos-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
const DEFAULT_FETCH_CONFIG: MoveFetchConfig = {
resourceChanges: false,
allEvents: true,
inputs: false,
inputs: true,
// for backward compatibility
supportMultisigFunc: true
}
Expand Down
7 changes: 6 additions & 1 deletion packages/sdk/src/aptos/ext/coin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ describe('coin test', () => {
const info = await getTokenInfoWithFallback(
'0xe4ccb6d39136469f376242c31b34d10515c8eaaa38092f804db8e08a8f53c5b2::assets_v1::EchoCoin002'
)

expect(info.decimals).to.eq(6)
})

test('get long coin info no exception', async () => {
await getTokenInfoWithFallback(
'0xc7efb4076dbe143cbcd98cfaaa929ecfc8f299203dfff63b95ccb6bfe19850fa::swap::LPToken<0xc7efb4076dbe143cbcd98cfaaa929ecfc8f299203dfff63b95ccb6bfe19850fa::swap::LPToken<0x25a64579760a4c64be0d692327786a6375ec80740152851490cfd0b53604cf95::coin::ETERN, 0x25a64579760a4c64be0d692327786a6375ec80740152851490cfd0b53604cf95::vault::IbToken<0x25a64579760a4c64be0d692327786a6375ec80740152851490cfd0b53604cf95::coin::ETERN>>, 0xc7efb4076dbe143cbcd98cfaaa929ecfc8f299203dfff63b95ccb6bfe19850fa::swap::LPToken<0x25a64579760a4c64be0d692327786a6375ec80740152851490cfd0b53604cf95::vault::IbToken<0x25a64579760a4c64be0d692327786a6375ec80740152851490cfd0b53604cf95::coin::ETERN>, 0xced3e98a47279b4d39a75fa8da867e2e8383d5d8ce7e59b2964a9469616a761b::coin::T>>'
)
})

test('have both token', async () => {
const info = await getTokenInfoWithFallback('0xa491095e3906fbca27b6fb7345d4ea407282c1aecbd50b2d2a42b1fa977bae30')
expect(info.tokenAddress).to.eq('0x8512b34017e087c3707748869ddc317d83f3fe70ab3a162abdc055c761ca9906::OBOT::OBOT')
Expand Down
10 changes: 7 additions & 3 deletions packages/sdk/src/aptos/ext/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,14 @@ async function getCoinTokenInfo(client: RichAptosClient, type: MoveStructId): Pr
throw Error('coin not existed: ' + type)
}

const paired = await coin.view.pairedMetadata(client, { typeArguments: [type] })
let faAddress
if (paired[0].vec[0]) {
faAddress = paired[0].vec[0] as `0x${string}`
try {
const paired = await coin.view.pairedMetadata(client, { typeArguments: [type] })
if (paired[0].vec[0]) {
faAddress = paired[0].vec[0] as `0x${string}`
}
} catch (e) {
console.debug("can't locate paired fa token for", type)
}

return {
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/sui/sui-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { getHandlerName, proxyProcessor } from '../utils/metrics.js'

export const DEFAULT_FETCH_CONFIG: MoveFetchConfig = {
resourceChanges: false,
allEvents: false,
inputs: false
allEvents: true,
inputs: true
}

export type IndexConfigure = Required<SuiBindOptions, 'startCheckpoint' | 'network'>
Expand Down

0 comments on commit 3acfd62

Please sign in to comment.