Skip to content

Commit

Permalink
Merge pull request #197 from ardriveapp/PE-6754-delegated-payments
Browse files Browse the repository at this point in the history
refactor: remove commented docker compose code,
  • Loading branch information
fedellen authored Oct 31, 2024
2 parents 15aea8b + e403f90 commit d7a6f5e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 19 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,8 @@ Wallet options:

Upload options:

- `--paid-by <paidBy...>` - An array of native addresses to pay for the upload
- `--ignore-approvals` - The CLI will normally use any delegated payment approvals for the upload. This flag will ignore any approvals and only use the connected wallet's balance for upload payment. Default: false
- `--paid-by <paidBy...>` - A list of native addresses to pay for the upload.
- `--ignore-approvals` - When no paid by is provided, the CLI will look for and use any received delegated payment approvals to pay for the upload. This flag will ignore any approvals and only use the connected wallet's balance for upload payment. Default: false
- `--use-signer-balance-first` - Use the connected wallet's balance before using any delegated payment approvals for the upload. Default: false

#### Commands
Expand Down Expand Up @@ -870,7 +870,7 @@ Command Options:
e.g:

```shell
turbo upload-file --file-path '../path/to/my/file.txt' --token ethereum --wallet-file ../path/to/eth/private/key.txt --paid-by '0x...address' '0x...another-address'
turbo upload-file --file-path '../path/to/my/file.txt' --token ethereum --wallet-file ../path/to/eth/private/key.txt --paid-by '0x...first-payer-address' '0x...second-payer-address' '0x...third-payer-address' 'etc...'
```

##### `price`
Expand Down
4 changes: 0 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ services:
# - '8545:8545'

upload-service:
# build:
# context: ../upload-service
image: ghcr.io/ardriveapp/upload-service:latest
ports:
- '3000:3000'
Expand Down Expand Up @@ -112,8 +110,6 @@ services:
start_period: 10s

payment-service:
# build:
# context: ../payment-service
image: ghcr.io/ardriveapp/payment-service:latest
ports:
- '4000:4000'
Expand Down
6 changes: 5 additions & 1 deletion src/cli/commands/createApproval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export async function createApproval(
});

console.log(
JSON.stringify({ message: 'Created approval:', ...result }, null, 2),
JSON.stringify(
{ message: 'Created delegated payment approval!', ...result },
null,
2,
),
);
}
4 changes: 2 additions & 2 deletions src/cli/commands/listApprovals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export async function listApprovals(
givenApprovals?.length === 0 && receivedApprovals?.length === 0;
const body = {
message:
`${hasApprovals ? 'No approvals found' : 'Approvals found'}` +
` for native address '${nativeAddress}'`,
`${hasApprovals ? 'No d' : 'D'}` +
`elegated payment approvals found for native address '${nativeAddress}'`,
givenApprovals,
receivedApprovals,
};
Expand Down
6 changes: 5 additions & 1 deletion src/cli/commands/revokeApprovals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export async function revokeApprovals(
});

console.log(
JSON.stringify({ message: 'Revoked approvals', revokedApprovals }, null, 2),
JSON.stringify(
{ message: 'Revoked delegated payment approvals!', revokedApprovals },
null,
2,
),
);
}
24 changes: 16 additions & 8 deletions src/common/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ import {
import { TurboHTTPService } from './http.js';
import { TurboWinstonLogger } from './logger.js';

export const createDelegatedPaymentApprovalTagName = 'x-approve-payment';
export const approvalAmountTagName = 'x-amount';
export const approvalExpiresBySecondsTagName = 'x-expires-seconds';
export const revokeDelegatePaymentApprovalTagName = 'x-delete-payment-approval';
export const delegatedPaymentTagNames = {
createDelegatedPaymentApproval: 'x-approve-payment',
approvalAmount: 'x-amount',
approvalExpiresBySeconds: 'x-expires-seconds',
revokeDelegatePaymentApproval: 'x-delete-payment-approval',
};

export const developmentUploadServiceURL = 'https://upload.ardrive.dev';
export const defaultUploadServiceURL = 'https://upload.ardrive.io';
Expand Down Expand Up @@ -323,13 +325,19 @@ export abstract class TurboAuthenticatedBaseUploadService
}: TurboCreateDelegatedPaymentApprovalParams): Promise<DelegatedPaymentApproval> {
const dataItemOpts = {
tags: [
{ name: createDelegatedPaymentApprovalTagName, value: approvedAddress },
{ name: approvalAmountTagName, value: approvedWincAmount.toString() },
{
name: delegatedPaymentTagNames.createDelegatedPaymentApproval,
value: approvedAddress,
},
{
name: delegatedPaymentTagNames.approvalAmount,
value: approvedWincAmount.toString(),
},
],
};
if (expiresBySeconds !== undefined) {
dataItemOpts.tags.push({
name: approvalExpiresBySecondsTagName,
name: delegatedPaymentTagNames.approvalExpiresBySeconds,
value: expiresBySeconds.toString(),
});
}
Expand Down Expand Up @@ -359,7 +367,7 @@ export abstract class TurboAuthenticatedBaseUploadService
const dataItemOpts = {
tags: [
{
name: revokeDelegatePaymentApprovalTagName,
name: delegatedPaymentTagNames.revokeDelegatePaymentApproval,
value: revokedAddress,
},
],
Expand Down

0 comments on commit d7a6f5e

Please sign in to comment.