Skip to content

Commit

Permalink
fix(jumpstart): fix jumpstart claim (#5136)
Browse files Browse the repository at this point in the history
### Description

Fix bugs causing error in claim status despite the claim itself
succeeds:
* wrong assumption about `jumpstartClaim` cloud function result format
* use of non-lowercased addresses

### Test plan

* Tested manually
* Updated unit rests

### Related issues

- Related to [RET-1004](https://linear.app/valora/issue/RET-1004)

### Backwards compatibility

Y

### Network scalability

No. 

Jumpstart works only for Celo. See also RET-1019.
  • Loading branch information
bakoushin committed Mar 20, 2024
1 parent 3bc5f91 commit 0695fa9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/jumpstart/jumpstartLinkHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('jumpstartLinkHandler', () => {
it('calls executeClaims with correct parameters', async () => {
;(fetchWithTimeout as jest.Mock).mockImplementation(() => ({
ok: true,
json: async () => ({ transactionHash: '0xHASH' }),
json: async () => ({ result: { transactionHash: '0xHASH' } }),
}))
const contractAddress = '0xTEST'

Expand Down
4 changes: 3 additions & 1 deletion src/jumpstart/jumpstartLinkHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ export async function executeClaims(

const { signature } = await kit.web3.eth.accounts.sign(messageHash, privateKey)

const { transactionHash } = await claimReward({
const response = await claimReward({
index: index.toString(),
beneficiary,
signature,
sendTo: userAddress,
assetType,
})

const transactionHash = response?.result?.transactionHash

if (transactionHash) {
transactionHashes.push(transactionHash)
}
Expand Down
4 changes: 2 additions & 2 deletions src/jumpstart/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ describe('dispatchPendingERC20Transactions', () => {
expect(Logger.warn).toHaveBeenCalledWith(
'WalletJumpstart',
'Claimed unknown tokenId',
'celo-alfajores:0xUNKNOWN'
'celo-alfajores:0xunknown'
)
})
})
Expand Down Expand Up @@ -292,7 +292,7 @@ describe('dispatchPendingERC721Transactions', () => {
nfts: [
{
tokenId: mockNftAllFields.tokenId,
contractAddress: mockNftAllFields.contractAddress,
contractAddress: mockNftAllFields.contractAddress.toLowerCase(),
tokenUri,
metadata,
media: [{ raw: metadata.image, gateway: metadata.image }],
Expand Down
4 changes: 2 additions & 2 deletions src/jumpstart/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function* dispatchPendingERC20Transactions(
address,
args: { token: tokenAddress, amount },
} of parsedLogs) {
const tokenId = getTokenId(networkId, tokenAddress)
const tokenId = getTokenId(networkId, tokenAddress.toLowerCase())

const token = tokensById[tokenId]
if (!token) {
Expand Down Expand Up @@ -179,7 +179,7 @@ export function* dispatchPendingERC721Transactions(
nfts: [
{
tokenId: tokenId.toString(),
contractAddress,
contractAddress: contractAddress.toLowerCase(),
tokenUri,
metadata,
media: [
Expand Down

0 comments on commit 0695fa9

Please sign in to comment.