Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@blindpay/cli",
"type": "module",
"version": "0.5.0",
"version": "0.6.0",
"description": "Blindpay CLI - manage receivers, bank accounts, payouts, payins, and more from the terminal",
"license": "MIT",
"author": "Blindpay <alves@blindpay.com> (https://blindpay.com/)",
Expand Down
24 changes: 12 additions & 12 deletions src/__tests__/resources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,9 @@ describe('Transfer Quotes', () => {
await resources.createTransferQuote({
walletId: 'bl_1',
senderToken: 'USDC',
receiverWalletAddress: '0xabc',
receiverToken: 'USDC',
receiverNetwork: 'polygon',
customerWalletAddress: '0xabc',
customerToken: 'USDC',
customerNetwork: 'polygon',
requestAmount: '1000',
amountReference: 'sender',
coverFees: true,
Expand All @@ -801,9 +801,9 @@ describe('Transfer Quotes', () => {
expect(lastCall().body).toEqual({
wallet_id: 'bl_1',
sender_token: 'USDC',
receiver_wallet_address: '0xabc',
receiver_token: 'USDC',
receiver_network: 'polygon',
customer_wallet_address: '0xabc',
customer_token: 'USDC',
customer_network: 'polygon',
request_amount: 1000,
amount_reference: 'sender',
cover_fees: true,
Expand All @@ -816,9 +816,9 @@ describe('Transfer Quotes', () => {
await resources.createTransferQuote({
walletId: 'bl_1',
senderToken: 'USDC',
receiverWalletAddress: '0xabc',
receiverToken: 'USDC',
receiverNetwork: 'polygon',
customerWalletAddress: '0xabc',
customerToken: 'USDC',
customerNetwork: 'polygon',
requestAmount: '1000',
amountReference: 'sender',
json: true,
Expand Down Expand Up @@ -846,20 +846,20 @@ describe('Terms of Service', () => {
mockResponse.body = { url: 'https://app.blindpay.com/e/terms-of-service?...' }
await resources.initiateTos({
idempotencyKey: 'idem-1',
receiverId: 're_xyz',
customerId: 're_xyz',
redirectUrl: 'https://example.com',
json: true,
})
expect(lastCall().method).toBe('POST')
expect(lastCall().url).toBe('https://api.blindpay.com/v1/e/instances/in_testInstance/tos')
expect(lastCall().body).toEqual({
idempotency_key: 'idem-1',
receiver_id: 're_xyz',
customer_id: 're_xyz',
redirect_url: 'https://example.com',
})
})

test('omits receiver_id and redirect_url from the body when not passed', async () => {
test('omits customer_id and redirect_url from the body when not passed', async () => {
mockResponse.body = { url: 'https://...' }
await resources.initiateTos({ idempotencyKey: 'idem-2', json: true })
expect(lastCall().body).toEqual({ idempotency_key: 'idem-2' })
Expand Down
16 changes: 8 additions & 8 deletions src/commands/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1075,9 +1075,9 @@ export async function trackTransfer(id: string, options: { json: boolean }) {
export async function createTransferQuote(options: {
walletId: string
senderToken: string
receiverWalletAddress: string
receiverToken: string
receiverNetwork: string
customerWalletAddress: string
customerToken: string
customerNetwork: string
requestAmount: string
amountReference: string
coverFees?: boolean
Expand All @@ -1089,9 +1089,9 @@ export async function createTransferQuote(options: {
const body: Record<string, any> = {
wallet_id: options.walletId,
sender_token: options.senderToken,
receiver_wallet_address: options.receiverWalletAddress,
receiver_token: options.receiverToken,
receiver_network: options.receiverNetwork,
customer_wallet_address: options.customerWalletAddress,
customer_token: options.customerToken,
customer_network: options.customerNetwork,
request_amount: parseAmount(options.requestAmount, 0, options.json),
amount_reference: options.amountReference,
cover_fees: options.coverFees ?? false,
Expand Down Expand Up @@ -1119,11 +1119,11 @@ export async function getInstanceFees(options: { json: boolean }) {
}

// Terms of Service
export async function initiateTos(options: { idempotencyKey: string, receiverId?: string, redirectUrl?: string, json: boolean }) {
export async function initiateTos(options: { idempotencyKey: string, customerId?: string, redirectUrl?: string, json: boolean }) {
try {
const ctx = resolveContext()
const body: Record<string, any> = { idempotency_key: options.idempotencyKey }
if (options.receiverId !== undefined) body.receiver_id = options.receiverId
if (options.customerId !== undefined) body.customer_id = options.customerId
if (options.redirectUrl !== undefined) body.redirect_url = options.redirectUrl
const res = await apiPost<{ url: string }>(ctx, `/v1/e/instances/${ctx.instanceId}/tos`, body)
if (!options.json) clack.log.success(`Open this URL to accept the Terms of Service:\n${res.url}`)
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,17 +739,17 @@ const transferQuotes = program.command('transfer_quotes').description('Manage tr
.addHelpText('after', `
Examples:
$ blindpay transfer_quotes create --wallet-id <id> --sender-token USDC \\
--receiver-wallet-address 0x... --receiver-token USDC --receiver-network polygon \\
--customer-wallet-address 0x... --customer-token USDC --customer-network polygon \\
--request-amount 1000 --amount-reference sender`)

transferQuotes
.command('create')
.description('Create a transfer quote')
.requiredOption('--wallet-id <id>', 'Sender wallet ID (bl_...)')
.requiredOption('--sender-token <token>', 'Sender token (USDC, USDT, ...)')
.requiredOption('--receiver-wallet-address <addr>', 'Receiver wallet address')
.requiredOption('--receiver-token <token>', 'Receiver token')
.requiredOption('--receiver-network <network>', 'Receiver network')
.requiredOption('--customer-wallet-address <addr>', 'Customer wallet address')
.requiredOption('--customer-token <token>', 'Customer token')
.requiredOption('--customer-network <network>', 'Customer network')
.requiredOption('--request-amount <amount>', 'Request amount in cents')
.requiredOption('--amount-reference <ref>', 'Amount reference (sender or receiver)')
.option('--cover-fees', 'Sender covers the fees', false)
Expand All @@ -775,13 +775,13 @@ const tos = program.command('tos').description('Initiate Terms of Service flow')
.addHelpText('after', `
Examples:
$ blindpay tos initiate --idempotency-key <key>
$ blindpay tos initiate --idempotency-key <key> --receiver-id <id> --redirect-url https://example.com`)
$ blindpay tos initiate --idempotency-key <key> --customer-id <id> --redirect-url https://example.com`)

tos
.command('initiate')
.description('Initiate a Terms of Service session and return a hosted URL')
.requiredOption('--idempotency-key <key>', 'Idempotency key')
.option('--receiver-id <id>', 'Receiver ID')
.option('--customer-id <id>', 'Customer ID')
.option('--redirect-url <url>', 'Redirect URL after acceptance')
.option('--json', 'Output as JSON', false)
.action(opts => initiateTos(opts))
Expand Down
Loading