Skip to content

Commit

Permalink
feat(locksmith): referrer on claim (#13082)
Browse files Browse the repository at this point in the history
* adding zksync file

* wip

* fix deployment script

* wip

* lint

* Updated docs for contract deployments

* undue change

* undue changes

* undue changes

* using referrer
  • Loading branch information
julien51 authored Dec 7, 2023
1 parent 8c17b39 commit dec5047
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion locksmith/src/controllers/v2/claimController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getTotalPurchasePriceInCrypto } from '../../utils/claim'
const ClaimBody = z.object({
data: z.string().optional(),
recipient: z.string().optional(),
referrer: z.string().optional(),
email: z
.string()
.email()
Expand All @@ -31,7 +32,9 @@ export const LOCKS_WITH_DISABLED_CLAIMS = [
* @returns
*/
export const claim: RequestHandler = async (request, response: Response) => {
const { data, recipient, email } = await ClaimBody.parseAsync(request.body)
const { data, recipient, email, referrer } = await ClaimBody.parseAsync(
request.body
)
const network = Number(request.params.network)
const lockAddress = normalizer.ethereumAddress(request.params.lockAddress)

Expand Down Expand Up @@ -160,6 +163,7 @@ export const claim: RequestHandler = async (request, response: Response) => {
owner,
network,
data,
referrer,
keyManager: email ? keyManagerAddress : owner,
},
async (_, transactionHash) => {
Expand Down
4 changes: 3 additions & 1 deletion locksmith/src/fulfillment/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,11 @@ export default class Dispatcher {
network: number
data?: string
keyManager?: string
referrer?: string
},
cb?: (error: any, hash: string | null) => Promise<unknown>
) {
const { network, lockAddress, owner, data, keyManager } = options
const { network, lockAddress, owner, data, keyManager, referrer } = options
const walletService = new WalletService(networks)

// get any purchaser, as the address is not required here.
Expand All @@ -396,6 +397,7 @@ export default class Dispatcher {
owner,
data,
keyManager,
referrer,
},
{ maxFeePerGas, maxPriorityFeePerGas },
cb
Expand Down
4 changes: 4 additions & 0 deletions packages/unlock-js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

# 0.40.2

- claim now supports a `referrer` param

# 0.40.1

- adding missing ABI for locksmiths
Expand Down
3 changes: 3 additions & 0 deletions packages/unlock-js/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,9 @@ paths:
recipient:
type: string
description: Recipient address for key
referrer:
type: string
description: Referrer address used to mint. This may get overwritten.

responses:
200:
Expand Down
2 changes: 1 addition & 1 deletion packages/unlock-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unlock-protocol/unlock-js",
"version": "0.40.1",
"version": "0.40.2",
"description": "This module provides libraries to include Unlock APIs inside a Javascript application.",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down

0 comments on commit dec5047

Please sign in to comment.