Skip to content

Commit

Permalink
chore(jumpstart): add networkId to claim request (#5138)
Browse files Browse the repository at this point in the history
### Description

As the title. Related to
valora-inc/valora-rest-api#921, to enable the
claim backend to use dynamic config to get the contract address.

### Test plan

n/a

### Related issues

n/a

### Backwards compatibility

Y

### Network scalability

Y
  • Loading branch information
kathaypacific committed Mar 21, 2024
1 parent c194b5f commit 6118c1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/jumpstart/jumpstartLinkHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('jumpstartLinkHandler', () => {
expect(result).toEqual(['0xHASH'])
expect(fetchWithTimeout).toHaveBeenCalledTimes(1)
expect(fetchWithTimeout).toHaveBeenCalledWith(
`https://api.alfajores.valora.xyz/walletJumpstart?index=1&beneficiary=${mockAccount}&signature=0xweb3-signature&sendTo=${mockAccount2}&assetType=erc20`,
`https://api.alfajores.valora.xyz/walletJumpstart?index=1&beneficiary=${mockAccount}&signature=0xweb3-signature&sendTo=${mockAccount2}&assetType=erc20&networkId=celo-alfajores`,
expect.any(Object),
expect.any(Number)
)
Expand Down
9 changes: 6 additions & 3 deletions src/jumpstart/jumpstartLinkHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export async function jumpstartLinkHandler(

const transactionHashes = (
await Promise.all([
executeClaims(kit, jumpstart, publicKey, userAddress, 'erc20', privateKey),
executeClaims(kit, jumpstart, publicKey, userAddress, 'erc721', privateKey),
executeClaims(kit, jumpstart, publicKey, userAddress, 'erc20', privateKey, networkId),
executeClaims(kit, jumpstart, publicKey, userAddress, 'erc721', privateKey, networkId),
])
).flat()

Expand All @@ -49,7 +49,8 @@ export async function executeClaims(
beneficiary: string,
userAddress: string,
assetType: 'erc20' | 'erc721',
privateKey: string
privateKey: string,
networkId: NetworkId
): Promise<Hash[]> {
let index = 0
const transactionHashes: Hash[] = []
Expand Down Expand Up @@ -81,6 +82,7 @@ export async function executeClaims(
signature,
sendTo: userAddress,
assetType,
networkId,
})

const transactionHash = response?.result?.transactionHash
Expand Down Expand Up @@ -113,6 +115,7 @@ export interface RewardInfo {
signature: string
sendTo: string
assetType: 'erc20' | 'erc721'
networkId: NetworkId
}

export async function claimReward(rewardInfo: RewardInfo) {
Expand Down

0 comments on commit 6118c1e

Please sign in to comment.