Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
33c8d31
feat: added single-invoice web component
sstefdev Nov 24, 2024
edbc904
Merge branch 'main' of github.com:RequestNetwork/web-components into …
sstefdev Dec 10, 2024
bafa730
Merge branch 'main' of github.com:RequestNetwork/web-components into …
sstefdev Dec 10, 2024
d6894bf
Merge branch 'main' of github.com:RequestNetwork/web-components into …
sstefdev Dec 18, 2024
fc6def0
Merge branch 'main' of github.com:RequestNetwork/web-components into …
sstefdev Jan 8, 2025
d3a2a49
feat: updated and cleaned single invoice component, removed unused va…
sstefdev Jan 9, 2025
5d71ab1
fix: updated gitignore, added loading skeleton, resolved comments
sstefdev Jan 13, 2025
f1a0703
Merge branch 'main' of github.com:RequestNetwork/web-components into …
sstefdev Jan 14, 2025
317fc67
fix: decoupling utils, using new token list
sstefdev Jan 15, 2025
0723463
Update README to include @requestnetwork/single-invoice in link cmds
MantisClone Jan 15, 2025
a1ab494
add single-invoice to the publish github action
MantisClone Jan 15, 2025
397c437
Add single-invoice to the README
MantisClone Jan 15, 2025
0998eab
fix: added single-invoice share and path prop
sstefdev Jan 20, 2025
38c20d9
Merge branch 'main' of github.com:RequestNetwork/web-components into …
sstefdev Jan 20, 2025
6d71f05
Merge branch '151-invoice-page---a-web-component-to-view-and-pay-a-si…
sstefdev Jan 20, 2025
f17559d
chore: decouple utils folder
sstefdev Jan 20, 2025
4f04b6f
fix: add check for no address in formatAddress function
sstefdev Jan 20, 2025
90b56ff
fix: payment error and decimal issue on dashboard
sstefdev Jan 20, 2025
4872241
feat: added encryption
sstefdev Jan 20, 2025
4cb5573
chore: add readme
sstefdev Jan 20, 2025
ada0771
fix: remove debug comments
sstefdev Jan 20, 2025
ca8c8e2
chore: add token list to the readme
sstefdev Jan 20, 2025
a2efcb2
fix: remove decryption for non encrypted requests, whenchanging the w…
sstefdev Jan 20, 2025
21b3c3d
fix: share svg viewbox
sstefdev Jan 20, 2025
547f2ad
chore: update create invoice form declaration file
sstefdev Jan 20, 2025
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 .github/workflows/npm-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- '@requestnetwork/create-invoice-form'
- '@requestnetwork/invoice-dashboard'
- '@requestnetwork/payment-widget'
- '@requestnetwork/single-invoice'
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
.turbo
dist
.svelte-kit
vite.congig.ts.timestamp*
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Usage depends on the component. See packages/\<package>/README.md
| [@requestnetwork/create-invoice-form](packages/create-invoice-form/README.md) | [![npm version](https://badge.fury.io/js/%40requestnetwork%2Fcreate-invoice-form.svg)](https://badge.fury.io/js/%40requestnetwork%2Fcreate-invoice-form) |
| [@requestnetwork/invoice-dashboard](packages/invoice-dashboard/README.md) | [![npm version](https://badge.fury.io/js/%40requestnetwork%2Finvoice-dashboard.svg)](https://badge.fury.io/js/%40requestnetwork%2Finvoice-dashboard) |
| [@requestnetwork/payment-widget](packages/payment-widget/README.md) | [![npm version](https://badge.fury.io/js/%40requestnetwork%2Fpayment-widget.svg)](https://badge.fury.io/js/%40requestnetwork%2Fpayment-widget) |
| [@requestnetwork/single-invoice](packages/single-invoice/README.md) | [![npm version](https://badge.fury.io/js/%40requestnetwork%2Fsingle-invoice.svg)](https://badge.fury.io/js/%40requestnetwork%2Fsingle-invoice) |
| [@requestnetwork/shared](packages/shared/README.md) | [![npm version](https://badge.fury.io/js/%40requestnetwork%2Fshared.svg)](https://badge.fury.io/js/%40requestnetwork%2Fshared) |


Expand Down Expand Up @@ -45,7 +46,7 @@ npm run link:all --app-path=../rn-checkout
cd <project>

# Use local packages instead of the deployed ones
npm link @requestnetwork/create-invoice-form @requestnetwork/invoice-dashboard
npm link @requestnetwork/create-invoice-form @requestnetwork/invoice-dashboard @requestnetwork/single-invoice
npm link @requestnetwork/payment-widget
```

Expand Down
35 changes: 35 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"build:dashboard": "turbo run build --filter=@requestnetwork/invoice-dashboard",
"build:stakeholder": "turbo run build --filter=@requestnetwork/add-stakeholder",
"build:payment-widget": "turbo run build --filter=@requestnetwork/payment-widget",
"build:single-invoice": "turbo run build --filter=@requestnetwork/single-invoice",
"link:react": "npm link $npm_config_app_path/node_modules/react $npm_config_app_path/node_modules/react-dom",
"link:all": "npm run link:react --app-path=$npm_config_app_path && for d in packages/*; do (cd $d && npm link); done",
"unlink:all": "for d in packages/*; do (cd $d && npm unlink); done"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
import { CurrencyTypes } from "@requestnetwork/types";
// Utils
import { getInitialFormData, prepareRequestParams } from "./utils";
import { config as defaultConfig } from "@requestnetwork/shared-utils/config";
import { calculateInvoiceTotals } from "@requestnetwork/shared-utils/invoiceTotals";
import {
config as defaultConfig,
calculateInvoiceTotals,
getCurrencySupportedNetworksForConversion,
initializeCreateInvoiceCurrencyManager,
initializeCurrencyManager,
} from "@requestnetwork/shared-utils/initCurrencyManager";
} from "@requestnetwork/shared-utils/index";
// Components
import { InvoiceForm, InvoiceView } from "./invoice";
import Button from "@requestnetwork/shared-components/button.svelte";
Expand Down
8 changes: 5 additions & 3 deletions packages/create-invoice-form/src/lib/invoice/form-view.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
import { CurrencyTypes } from "@requestnetwork/types";

// Utils
import { config as defaultConfig } from "@requestnetwork/shared-utils/config";
import { calculateItemTotal } from "@requestnetwork/shared-utils/invoiceTotals";
import { formatDate } from "@requestnetwork/shared-utils/formatDate";
import {
formatDate,
calculateItemTotal,
config as defaultConfig,
} from "@requestnetwork/shared-utils/index";

export let defaultCurrencies;
export let config: IConfig;
Expand Down
9 changes: 6 additions & 3 deletions packages/create-invoice-form/src/lib/invoice/form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
import type { IConfig, CustomFormData } from "@requestnetwork/shared-types";

// Utils
import { calculateItemTotal } from "@requestnetwork/shared-utils/invoiceTotals";
import { checkAddress } from "@requestnetwork/shared-utils/checkEthAddress";
import { inputDateFormat } from "@requestnetwork/shared-utils/formatDate";
import {
checkAddress,
inputDateFormat,
calculateItemTotal,
} from "@requestnetwork/shared-utils/index";

import { CurrencyTypes, CipherProviderTypes } from "@requestnetwork/types";
import isEmail from "validator/es/lib/isEmail";

Expand Down
48 changes: 39 additions & 9 deletions packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@
import Tooltip from "@requestnetwork/shared-components/tooltip.svelte";
// Icons
import Download from "@requestnetwork/shared-icons/download.svelte";
import Share from "@requestnetwork/shared-icons/share.svelte";
// Utils
import { formatDate } from "@requestnetwork/shared-utils/formatDate";
import { checkStatus } from "@requestnetwork/shared-utils/checkStatus";
import { calculateItemTotal } from "@requestnetwork/shared-utils/invoiceTotals";
import { exportToPDF } from "@requestnetwork/shared-utils/generateInvoice";
import { getCurrencyFromManager } from "@requestnetwork/shared-utils/getCurrency";
import { onMount } from "svelte";
import {
exportToPDF,
formatDate,
checkStatus,
getEthersSigner,
calculateItemTotal,
getCurrencyFromManager,
getConversionPaymentValues,
} from "@requestnetwork/shared-utils/index";
import { formatUnits } from "viem";
import { getConversionPaymentValues } from "../../utils/getConversionPaymentValues";
import { getEthersSigner } from "../../utils";

interface EntityInfo {
value: string;
Expand All @@ -49,6 +51,7 @@
export let currencyManager: any;
export let isRequestPayed: boolean;
export let wagmiConfig: any;
export let singleInvoicePath: string;

let network: string | undefined = request?.currencyInfo?.network || "mainnet";
let currency: CurrencyTypes.CurrencyDefinition | undefined =
Expand Down Expand Up @@ -512,7 +515,12 @@
zksyncera: "0x144",
base: "0x2105",
};
return networkIds[network];

const networkId = networkIds[network];
if (!networkId) {
console.warn(`Unknown network: ${network}`);
}
return networkId;
}

// FIXME: Add rounding functionality
Expand Down Expand Up @@ -599,6 +607,16 @@
}));
}
}

// Add debug logging to see what's happening
$: {
const hexStringChain = "0x" + account?.chainId?.toString(16);
const networkId = getNetworkIdFromNetworkName(network || "mainnet");

correctChain =
hexStringChain.toLowerCase() === String(networkId).toLowerCase() ||
Number(hexStringChain) === Number(networkId);
}
</script>

<div
Expand Down Expand Up @@ -639,6 +657,17 @@
}}
/>
</Tooltip>
{#if singleInvoicePath}
<Tooltip text="Share Invoice">
<Share
onClick={() => {
const shareUrl = `${window.location.origin}${singleInvoicePath}/${request.requestId}`;
navigator.clipboard.writeText(shareUrl);
toast.success("Share link copied to clipboard!");
}}
/>
</Tooltip>
{/if}
</h2>
<div class="invoice-address">
<h2>From:</h2>
Expand Down Expand Up @@ -948,6 +977,7 @@
.invoice-number svg {
width: 13px;
height: 13px;
cursor: pointer;
}

.invoice-address {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface InvoiceDashboardProps {
config: IConfig;
wagmiConfig: WagmiConfig;
requestNetwork: RequestNetwork | null | undefined;
singleInvoicePath: string;
}
/**
* InvoiceDashboard is a React component that integrates with the Request Network to manage and display invoices.
Expand All @@ -24,6 +25,7 @@ export interface InvoiceDashboardProps {
* config={config}
* wagmiConfig={wagmiConfig}
* requestNetwork={requestNetwork}
* singleInvoicePath={singleInvoicePath}
* />
*/
declare const InvoiceDashboard: React.FC<InvoiceDashboardProps>;
Expand Down
20 changes: 13 additions & 7 deletions packages/invoice-dashboard/src/lib/view-requests.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,22 @@
import type { IConfig } from "@requestnetwork/shared-types";
import type { RequestNetwork } from "@requestnetwork/request-client.js";
// Utils
import { config as defaultConfig } from "@requestnetwork/shared-utils/config";
import { initializeCurrencyManager } from "@requestnetwork/shared-utils/initCurrencyManager";
import { exportToPDF } from "@requestnetwork/shared-utils/generateInvoice";
import { getCurrencyFromManager } from "@requestnetwork/shared-utils/getCurrency";
import {
debounce,
checkStatus,
formatUnits,
formatAddress,
getEthersSigner,
exportToPDF,
getCurrencyFromManager,
config as defaultConfig,
initializeCurrencyManager,
} from "@requestnetwork/shared-utils/index";
import { CurrencyManager } from "@requestnetwork/currency";
import { onDestroy, onMount, tick } from "svelte";
import { formatUnits } from "viem";
import { debounce, formatAddress, getEthersSigner } from "../utils";
import { Drawer, InvoiceView } from "./dashboard";
import { getPaymentNetworkExtension } from "@requestnetwork/payment-detection";
import { CipherProviderTypes, CurrencyTypes } from "@requestnetwork/types";
import { checkStatus } from "@requestnetwork/shared-utils/checkStatus";
import { ethers } from "ethers";

interface CipherProvider extends CipherProviderTypes.ICipherProvider {
Expand All @@ -63,6 +67,7 @@
export let config: IConfig;
export let wagmiConfig: WagmiConfig;
export let requestNetwork: RequestNetwork | null | undefined;
export let singleInvoicePath: string;

let cipherProvider: CipherProvider | undefined;

Expand Down Expand Up @@ -903,6 +908,7 @@
bind:currencyManager
config={activeConfig}
request={activeRequest}
{singleInvoicePath}
/>
{/if}
</Drawer>
Expand Down
21 changes: 0 additions & 21 deletions packages/invoice-dashboard/src/utils/formatAddress.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<script lang="ts">
import { fade } from "svelte/transition";
import { exportToPDF } from "@requestnetwork/shared-utils/generateInvoice";
import { getCurrencyFromManager } from "@requestnetwork/shared-utils/getCurrency";
import { initializeCurrencyManager } from "@requestnetwork/shared-utils/initCurrencyManager";
import {
exportToPDF,
getCurrencyFromManager,
initializeCurrencyManager,
} from "@requestnetwork/shared-utils/index";

import Toaster from "@requestnetwork/shared-components/sonner.svelte";
import { toast } from "svelte-sonner";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { onMount } from "svelte";
import type { Web3Modal } from "@web3modal/ethers5";
import { formatAddress } from "@requestnetwork/shared-utils/formatAddress";
import { formatAddress } from "@requestnetwork/shared-utils/index";
export let web3Modal: Web3Modal | null;
export let isConnected: boolean = false;

Expand Down
6 changes: 3 additions & 3 deletions packages/payment-widget/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"baseUrl": ".",
"paths": {
"$src/*": ["src/*"],
"$utils/*": ["src/lib/utils/*"],
},
"$utils/*": ["src/lib/utils/*"]
}
},
"include": ["src/**/*", "src/*.d.ts"],
"include": ["src/**/*", "src/*.d.ts"]
}
Loading
Loading