Skip to content

Commit

Permalink
fix: keep types unchanged after API response upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
dasanra committed Jan 28, 2025
1 parent 33a8df8 commit bf2751c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
14 changes: 12 additions & 2 deletions packages/api-kit/src/SafeApiKit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ class SafeApiKit {
// FIXME remove when the transaction service returns the singleton property instead of masterCopy
if (!response?.singleton) {
const { masterCopy, ...rest } = response
return { ...rest, singleton: masterCopy } as SafeInfoResponse
return { ...rest, singleton: masterCopy, nonce: Number(response.nonce) } as SafeInfoResponse
}

return response as SafeInfoResponse
return { ...response, nonce: Number(response.nonce) } as SafeInfoResponse
})
}

Expand Down Expand Up @@ -851,6 +851,16 @@ class SafeApiKit {
return sendRequest({
url: `${this.#txServiceBaseUrl}/v1/safe-operations/${safeOperationHash}/`,
method: HttpMethod.Get
}).then((response: any) => {

Check warning on line 854 in packages/api-kit/src/SafeApiKit.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected any. Specify a different type
return {
...response,
nonce: Number(response.nonce),
callGasLimit: Number(response.callGasLimit),
verificationGasLimit: Number(response.verificationcallGasLimit),
preVerificationGas: Number(response.preVerificationGas),
maxFeePerGas: Number(response.maxFeePerGas),
maxPriorityFeePerGas: Number(response.maxPriorityFeePerGas)
} as SafeOperationResponse
})
}

Expand Down
21 changes: 15 additions & 6 deletions packages/api-kit/tests/e2e/getSafeOperationsByAddress.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,23 @@ describe('getSafeOperationsByAddress', () => {
chai.expect(safeOperation.userOperation).to.have.property('ethereumTxHash')
chai.expect(safeOperation.userOperation).to.have.property('sender').to.eq(SAFE_ADDRESS)
chai.expect(safeOperation.userOperation).to.have.property('userOperationHash')
chai.expect(safeOperation.userOperation).to.have.property('nonce')
chai.expect(safeOperation.userOperation).to.have.property('nonce').to.be.a('number')
chai.expect(safeOperation.userOperation).to.have.property('initCode')
chai.expect(safeOperation.userOperation).to.have.property('callData')
chai.expect(safeOperation.userOperation).to.have.property('callGasLimit')
chai.expect(safeOperation.userOperation).to.have.property('verificationGasLimit')
chai.expect(safeOperation.userOperation).to.have.property('preVerificationGas')
chai.expect(safeOperation.userOperation).to.have.property('maxFeePerGas')
chai.expect(safeOperation.userOperation).to.have.property('maxPriorityFeePerGas')
chai.expect(safeOperation.userOperation).to.have.property('callGasLimit').to.be.a('number')
chai
.expect(safeOperation.userOperation)
.to.have.property('verificationGasLimit')
.to.be.a('number')
chai
.expect(safeOperation.userOperation)
.to.have.property('preVerificationGas')
.to.be.a('number')
chai.expect(safeOperation.userOperation).to.have.property('maxFeePerGas').to.be.a('number')
chai
.expect(safeOperation.userOperation)
.to.have.property('maxPriorityFeePerGas')
.to.be.a('number')
chai.expect(safeOperation.userOperation).to.have.property('paymaster')
chai.expect(safeOperation.userOperation).to.have.property('paymasterData')
chai.expect(safeOperation.userOperation).to.have.property('signature')
Expand Down

0 comments on commit bf2751c

Please sign in to comment.