@powerhousedao/contributor-billing 0.0.83 → 0.0.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoiceToGnosis.d.ts","sourceRoot":"","sources":["../../../editors/invoice/invoiceToGnosis.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"invoiceToGnosis.d.ts","sourceRoot":"","sources":["../../../editors/invoice/invoiceToGnosis.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAUnD,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,GAAG,CAAC;IACd,QAAQ,EAAE,GAAG,CAAC;CACf;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA+QnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
3
|
import { actions } from "../../document-models/invoice/index.js";
|
|
4
4
|
import { generateId } from "document-model";
|
|
5
5
|
let GRAPHQL_URL = "http://localhost:4001/graphql/invoice";
|
|
@@ -9,12 +9,23 @@ if (!window.document.baseURI.includes("localhost")) {
|
|
|
9
9
|
const InvoiceToGnosis = ({ docState, dispatch, }) => {
|
|
10
10
|
const [isLoading, setIsLoading] = useState(false);
|
|
11
11
|
const [error, setError] = useState(null);
|
|
12
|
-
const [responseData, setResponseData] = useState(null);
|
|
13
12
|
const [invoiceStatusResponse, setInvoiceStatusResponse] = useState(null);
|
|
14
13
|
const [safeTxHash, setsafeTxHash] = useState(null);
|
|
14
|
+
const [safeAddress, setSafeAddress] = useState(null);
|
|
15
15
|
const currency = docState.currency;
|
|
16
16
|
const chainName = docState.issuer.paymentRouting.wallet.chainName;
|
|
17
17
|
const invoiceStatus = docState.status;
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
// set safeADdress from processorRef
|
|
20
|
+
if (docState.payments.length < 1)
|
|
21
|
+
return;
|
|
22
|
+
const lastPayment = docState.payments[docState.payments.length - 1].processorRef;
|
|
23
|
+
console.log(lastPayment);
|
|
24
|
+
const retrievedSafeAddress = lastPayment.split(":");
|
|
25
|
+
if (retrievedSafeAddress[0]) {
|
|
26
|
+
setSafeAddress(retrievedSafeAddress[0]);
|
|
27
|
+
}
|
|
28
|
+
}, [docState.payments.length]);
|
|
18
29
|
const TOKEN_ADDRESSES = {
|
|
19
30
|
BASE: {
|
|
20
31
|
USDC: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
@@ -93,16 +104,17 @@ const InvoiceToGnosis = ({ docState, dispatch, }) => {
|
|
|
93
104
|
if (data.success) {
|
|
94
105
|
const dataObj = typeof data.data === "string" ? JSON.parse(data.data) : data.data;
|
|
95
106
|
setsafeTxHash(dataObj.txHash);
|
|
107
|
+
setSafeAddress(dataObj.safeAddress);
|
|
96
108
|
if (invoiceStatus === "ACCEPTED") {
|
|
97
109
|
dispatch(actions.schedulePayment({
|
|
98
110
|
id: generateId(),
|
|
99
|
-
processorRef: dataObj.txHash
|
|
111
|
+
processorRef: `${dataObj.safeAddress}:${dataObj.txHash}`,
|
|
100
112
|
}));
|
|
101
113
|
}
|
|
102
114
|
else {
|
|
103
115
|
dispatch(actions.addPayment({
|
|
104
116
|
id: generateId(),
|
|
105
|
-
processorRef: dataObj.txHash
|
|
117
|
+
processorRef: `${dataObj.safeAddress}:${dataObj.txHash}`,
|
|
106
118
|
confirmed: false,
|
|
107
119
|
}));
|
|
108
120
|
}
|
|
@@ -157,10 +169,10 @@ const InvoiceToGnosis = ({ docState, dispatch, }) => {
|
|
|
157
169
|
? "Processing..."
|
|
158
170
|
: invoiceStatus === "ACCEPTED"
|
|
159
171
|
? "Schedule Payment in Gnosis Safe"
|
|
160
|
-
: "Reschedule Payment in Gnosis Safe" })), error && (_jsx("div", { className: "text-red-500 bg-red-50 p-3 rounded-md", children: error })), safeTxHash && (_jsxs("div", { className: "bg-gray-50 mt-4 rounded-md space-y-2", children: [_jsx("a", { href: `https://app.safe.global/transactions/queue?safe=${urlChainName}
|
|
172
|
+
: "Reschedule Payment in Gnosis Safe" })), error && (_jsx("div", { className: "text-red-500 bg-red-50 p-3 rounded-md", children: error })), safeTxHash && (_jsxs("div", { className: "bg-gray-50 mt-4 rounded-md space-y-2", children: [_jsx("a", { href: `https://app.safe.global/transactions/queue?safe=${urlChainName}:${safeAddress}`, target: "_blank", rel: "noopener noreferrer", className: "text-blue-500 hover:text-blue-600 underline block", children: linkText }), _jsxs("p", { className: "font-medium", children: ["Safe Transaction Hash:", _jsx("span", { className: "font-mono text-sm ml-2 break-all", children: safeTxHash })] })] })), !safeTxHash &&
|
|
161
173
|
!error &&
|
|
162
174
|
invoiceStatus === "PAYMENTSCHEDULED" &&
|
|
163
|
-
docState.payments.length > 0 && (_jsx(_Fragment, { children: docState.payments[docState.payments.length - 1].issue !== "" ? (_jsx("div", { className: "mt-4", children: _jsxs("p", { className: "text-red-700 font-medium", children: ["Issue: ", docState.payments[docState.payments.length - 1].issue] }) })) : (_jsxs("div", { className: "mt-4", children: [_jsx("div", { className: "invoice-link text-blue-900 hover:text-blue-600", children: _jsx("a", { className: "view-invoice-button", href: `https://app.safe.global/transactions/queue?safe=${urlChainName}
|
|
175
|
+
docState.payments.length > 0 && (_jsx(_Fragment, { children: docState.payments[docState.payments.length - 1].issue !== "" ? (_jsx("div", { className: "mt-4", children: _jsxs("p", { className: "text-red-700 font-medium", children: ["Issue: ", docState.payments[docState.payments.length - 1].issue] }) })) : (_jsxs("div", { className: "mt-4", children: [_jsx("div", { className: "invoice-link text-blue-900 hover:text-blue-600", children: _jsx("a", { className: "view-invoice-button", href: `https://app.safe.global/transactions/queue?safe=${urlChainName}:${safeAddress}`, target: "_blank", rel: "noopener noreferrer", children: linkText }) }), _jsxs("p", { className: "mt-4 font-medium", children: ["Safe Transaction Hash:", _jsx("span", { className: "font-mono text-sm ml-2 break-all", children: docState.payments[docState.payments.length - 1]
|
|
164
176
|
.processorRef })] })] })) })), invoiceStatusResponse && (_jsxs("div", { className: "bg-gray-50 p-4 rounded-md", children: [_jsx("p", { className: "font-medium", children: "Payment Details:" }), _jsx("p", { className: "text-gray-700", children: invoiceStatusResponse })] }))] }));
|
|
165
177
|
};
|
|
166
178
|
export default InvoiceToGnosis;
|
|
@@ -4,7 +4,7 @@ import { OperationType } from '@safe-global/types-kit';
|
|
|
4
4
|
import { ethers, AbiCoder } from 'ethers';
|
|
5
5
|
import dotenv from 'dotenv';
|
|
6
6
|
dotenv.config();
|
|
7
|
-
const safeAddress = process.env.
|
|
7
|
+
const safeAddress = process.env.PRODUCTION_SAFE_ADDRESS;
|
|
8
8
|
if (!safeAddress) {
|
|
9
9
|
throw new Error('Missing SAFE_ADDRESS in .env');
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/contributor-billing",
|
|
3
3
|
"description": "Document models that help contributors of open organisations get paid anonymously for their work on a monthly basis.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.84",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|