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
591 changes: 469 additions & 122 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions packages/create-invoice-form/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @requestnetwork/create-invoice-form

## 0.11.11

### Patch Changes

- Fix Lit Protocol Encryption Issues

## 0.11.10

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/create-invoice-form/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@requestnetwork/create-invoice-form",
"version": "0.11.10",
"version": "0.11.11",
"main": "./dist/web-component.umd.cjs",
"scripts": {
"dev": "vite dev",
Expand Down Expand Up @@ -33,8 +33,8 @@
"!dist/**/*.spec.*"
],
"dependencies": {
"@requestnetwork/data-format": "0.19.4",
"@requestnetwork/request-client.js": "0.53.0",
"@requestnetwork/data-format": "0.19.5",
"@requestnetwork/request-client.js": "0.54.0",
"@wagmi/core": "^2.15.2",
"validator": "^13.12.0",
"viem": "^2.21.53"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@
import Modal from "@requestnetwork/shared-components/modal.svelte";
import { EncryptionTypes, CipherProviderTypes } from "@requestnetwork/types";

interface CipherProvider extends CipherProviderTypes.ICipherProvider {
disconnectWallet: () => void;
}

export let config: IConfig;
export let wagmiConfig: WagmiConfig;
export let requestNetwork: RequestNetwork | null | undefined;
export let currencies: CurrencyTypes.CurrencyInput[] = [];
let cipherProvider: CipherProviderTypes.ICipherProvider | undefined;
let cipherProvider: CipherProvider | undefined;

let account: GetAccountReturnType;
let isTimeout = false;
Expand Down Expand Up @@ -115,11 +119,12 @@
totalAmount: 0,
};

$: cipherProvider = requestNetwork?.getCipherProvider();
$: cipherProvider = requestNetwork?.getCipherProvider() as CipherProvider;

$: {
if (wagmiConfig) {
account = getAccount(wagmiConfig);
cipherProvider?.disconnectWallet();
}
}

Expand Down
6 changes: 6 additions & 0 deletions packages/invoice-dashboard/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @requestnetwork/invoice-dashboard

## 0.11.9

### Patch Changes

- Fix Lit Protocol Encryption Issues

## 0.11.8

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/invoice-dashboard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@requestnetwork/invoice-dashboard",
"version": "0.11.8",
"version": "0.11.9",
"main": "./dist/web-component.umd.cjs",
"scripts": {
"dev": "vite dev",
Expand Down Expand Up @@ -37,9 +37,9 @@
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"dependencies": {
"@requestnetwork/payment-detection": "0.48.0",
"@requestnetwork/payment-processor": "0.51.0",
"@requestnetwork/request-client.js": "0.53.0",
"@requestnetwork/payment-detection": "0.49.0",
"@requestnetwork/payment-processor": "0.52.0",
"@requestnetwork/request-client.js": "0.54.0",
"@wagmi/connectors": "^5.5.3",
"@wagmi/core": "^2.15.2",
"ethers": "^5.7.2",
Expand Down
127 changes: 45 additions & 82 deletions packages/invoice-dashboard/src/lib/view-requests.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,22 @@
import { checkStatus } from "@requestnetwork/shared-utils/checkStatus";
import { ethers } from "ethers";

interface CipherProvider extends CipherProviderTypes.ICipherProvider {
getSessionSignatures: (
signer: ethers.Signer,
walletAddress: `0x${string}`,
domain: string,
statement: string
) => Promise<any>;
disconnectWallet: () => void;
}

export let config: IConfig;
export let wagmiConfig: WagmiConfig;
export let requestNetwork: RequestNetwork | null | undefined;
export let currencies: CurrencyTypes.CurrencyInput[] = [];

let cipherProvider:
| (CipherProviderTypes.ICipherProvider & {
getSessionSignatures: (
signer: ethers.Signer,
walletAddress: `0x${string}`
) => Promise<any>;
})
| undefined;
let cipherProvider: CipherProvider | undefined;

let sliderValueForDecryption = JSON.parse(
localStorage?.getItem("isDecryptionEnabled") ?? "false"
Expand All @@ -72,7 +75,7 @@
let activeConfig = config ? config : defaultConfig;
let mainColor = activeConfig.colors.main;
let secondaryColor = activeConfig.colors.secondary;
let account: GetAccountReturnType = wagmiConfig && getAccount(wagmiConfig);
let account: GetAccountReturnType | undefined = wagmiConfig && getAccount(wagmiConfig);

let loading = false;
let searchQuery = "";
Expand All @@ -87,8 +90,6 @@
})
| undefined;
let currencyManager: CurrencyManager;
let previousWalletAddress: string | undefined;
let previousNetwork: string | undefined;

let columns = {
issuedAt: false,
Expand All @@ -102,63 +103,45 @@
let sortOrder = "desc";
let sortColumn = "timestamp";

let previousAddress: string | undefined;
const handleWalletConnection = async () => {
account = getAccount(wagmiConfig);
await loadRequests(sliderValueForDecryption, account, requestNetwork);
};

$: {
if (wagmiConfig) {
const newAccount = getAccount(wagmiConfig);
if (newAccount?.address !== previousAddress) {
account = newAccount;
previousAddress = newAccount?.address;

if (newAccount?.address) {
tick().then(() => {
enableDecryption();
getRequests();
});
} else {
requests = [];
activeRequest = undefined;
previousWalletAddress = undefined;
previousNetwork = undefined;
}
}
}
}
const handleWalletDisconnection = () => {
cipherProvider?.disconnectWallet();
requests = [];
activeRequest = undefined;
cipherProvider = undefined;
account = undefined;
};

let unwatchAccount: WatchAccountReturnType | undefined;
const handleWalletChange = (data: any) => {
if (data?.address) {
handleWalletConnection();
} else {
handleWalletDisconnection();
}
};

onMount(() => {
unwatchAccount = watchAccount(wagmiConfig, {
onChange(data) {
if (data?.address !== previousAddress) {
account = data;
previousAddress = data?.address;

if (data?.address) {
getRequests();
} else {
requests = [];
activeRequest = undefined;
previousWalletAddress = undefined;
previousNetwork = undefined;
}
}
tick().then(() => {
handleWalletChange(data);
});
},
});
});

let unwatchAccount: WatchAccountReturnType | undefined;

onDestroy(() => {
if (typeof unwatchAccount === "function") unwatchAccount();
});

$: cipherProvider =
requestNetwork?.getCipherProvider() as CipherProviderTypes.ICipherProvider & {
getSessionSignatures: (
signer: ethers.Signer,
walletAddress: `0x${string}`
) => Promise<any>;
};
requestNetwork?.getCipherProvider() as CipherProvider;

$: {
signer = account?.address;
Expand All @@ -170,9 +153,8 @@
currencyManager = initializeCurrencyManager(currencies);
});

const getRequests = async () => {
const getRequests = async (account: GetAccountReturnType, requestNetwork: RequestNetwork | undefined | null) => {
if (!account?.address || !requestNetwork) return;
loading = true;

try {
const requestsData = await requestNetwork?.fromIdentity({
Expand All @@ -184,8 +166,6 @@
.sort((a, b) => b.timestamp - a.timestamp);
} catch (error) {
console.error("Failed to fetch requests:", error);
} finally {
loading = false;
}
};

Expand All @@ -211,25 +191,6 @@
let currentPage = 1;
let totalPages = 1;

$: {
const currentWalletAddress = account?.address;
const currentNetwork = account?.chainId?.toString();

if (
currentWalletAddress &&
currentWalletAddress !== previousWalletAddress
) {
getRequests();
previousWalletAddress = currentWalletAddress;

activeRequest = undefined;
}

if (currentNetwork && currentNetwork !== previousNetwork) {
previousNetwork = currentNetwork;
}
}

$: {
if (sortColumn && sortOrder) {
requests = [...(requests ?? [])].sort((a, b) => {
Expand Down Expand Up @@ -422,13 +383,15 @@
activeRequest = undefined;
};

const enableDecryption = async () => {
const loadRequests = async (sliderValue: string, currentAccount: GetAccountReturnType, currentRequestNetwork: RequestNetwork | undefined | null) => {
if (!currentAccount?.address || !currentRequestNetwork && !cipherProvider) return;

loading = true;
if (sliderValueForDecryption === "on") {
if (sliderValue === "on") {
try {
const signer = await getEthersSigner(wagmiConfig);
if (signer && account?.address) {
await cipherProvider?.getSessionSignatures(signer, account.address);
if (signer && currentAccount?.address) {
await cipherProvider?.getSessionSignatures(signer, currentAccount.address, window.location.host, "Sign in to Lit Protocol through Request Network");
cipherProvider?.enableDecryption(true);
localStorage?.setItem("isDecryptionEnabled", JSON.stringify(true));
}
Expand All @@ -442,10 +405,10 @@
cipherProvider?.enableDecryption(false);
localStorage?.setItem("isDecryptionEnabled", JSON.stringify(false));
}
await getRequests();
await getRequests(currentAccount, currentRequestNetwork);
loading = false;
};
$: sliderValueForDecryption, enableDecryption();
$: loadRequests(sliderValueForDecryption, account, requestNetwork);
</script>

<div
Expand Down
6 changes: 6 additions & 0 deletions packages/payment-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @requestnetwork/payment-widget

## 0.3.7

### Patch Changes

- Fix Lit Protocol Encryption Issues

## 0.3.6

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/payment-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@requestnetwork/payment-widget",
"version": "0.3.6",
"version": "0.3.7",
"main": "./dist/web-component.umd.cjs",
"scripts": {
"dev": "vite dev",
Expand Down Expand Up @@ -56,9 +56,9 @@
"access": "public"
},
"dependencies": {
"@requestnetwork/payment-processor": "0.51.0",
"@requestnetwork/request-client.js": "0.53.0",
"@requestnetwork/web3-signature": "0.8.4",
"@requestnetwork/payment-processor": "0.52.0",
"@requestnetwork/request-client.js": "0.54.0",
"@requestnetwork/web3-signature": "0.8.5",
"@web3modal/ethers5": "^5.0.11",
"ethers": "^5.7.2",
"vite-plugin-node-polyfills": "^0.22.0"
Expand Down
Loading