Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APIKit] Type mistmatch between txs-service and SDK #1088

Open
gjeanmart opened this issue Dec 23, 2024 · 0 comments
Open

[APIKit] Type mistmatch between txs-service and SDK #1088

gjeanmart opened this issue Dec 23, 2024 · 0 comments

Comments

@gjeanmart
Copy link

gjeanmart commented Dec 23, 2024

Description

There is a mismatch between the APIKit result and the transaction-service response, leading to an undefined value.

The transaction-service returns a masterCopy field as part of the /api/v1/safes/<safe>/ endpoint response:

image

However, APIKit expects and handles this value under the singleton field:

https://github.com/safe-global/safe-core-sdk/blob/main/packages/api-kit/src/types/safeTransactionServiceTypes.ts#L44-L54

export type SafeInfoResponse = {
  readonly address: string
  readonly nonce: number
  readonly threshold: number
  readonly owners: string[]
  readonly singleton: string // <<<<< HERE
  readonly modules: string[]
  readonly fallbackHandler: string
  readonly guard: string
  readonly version: string
}

This discrepancy results in safe.singleton being undefined when calling:

const safe = await apiKit.getSafeInfo(safe)

Environment

  • Safe Core SDK versions:
    • api-kit: 2.5.4
    • protocol-kit:
    • relay-kit:
    • types-kit:
    • sdk-starter-kit:
  • Safe contract version:
  • Environment:
    • browser
    • non-browser

Steps to reproduce

const safe = '0x...' // some safe on Mainnet
const apiKit = new SafeApiKit({
  chainId: 1
})
const safe = await apiKit.getSafeInfo(safe)
expect(safe.singleton).toBeDefined() // fails

Expected result

The response should consistently return a singleton field, correctly mapping the masterCopy value from the transaction-service response.

Additional context

Workaround:

const safe = '0x...' // some safe on Mainnet
const apiKit = new SafeApiKit({
  chainId: 1
})
const safe = await apiKit.getSafeInfo(safe)
expect(safe['masterCopy']).toBeDefined() // success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant