@phala/pay 0.8.2 → 0.9.0
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.
- package/README.md +33 -58
- package/THIRD_PARTY_NOTICES +25 -0
- package/dist/chains.d.ts +2 -0
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +11 -2
- package/dist/chains.js.map +1 -1
- package/dist/checkout.d.ts +4 -2
- package/dist/checkout.d.ts.map +1 -1
- package/dist/checkout.js +18 -3
- package/dist/checkout.js.map +1 -1
- package/dist/deposit-address.js +2 -2
- package/dist/deposit-address.js.map +1 -1
- package/dist/icon-names.d.ts +7 -0
- package/dist/icon-names.d.ts.map +1 -0
- package/dist/icon-names.js +15 -0
- package/dist/icon-names.js.map +1 -0
- package/dist/icon-svg.d.ts +6 -0
- package/dist/icon-svg.d.ts.map +1 -0
- package/dist/icon-svg.js +13 -0
- package/dist/icon-svg.js.map +1 -0
- package/dist/icons.d.ts +5 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +27 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/request.d.ts +2 -0
- package/dist/request.d.ts.map +1 -1
- package/dist/request.js +7 -0
- package/dist/request.js.map +1 -1
- package/dist/shared/checkout-params.d.ts +7 -0
- package/dist/shared/checkout-params.d.ts.map +1 -0
- package/dist/shared/checkout-params.js +2 -0
- package/dist/shared/checkout-params.js.map +1 -0
- package/package.json +18 -31
- package/src/chains.ts +12 -2
- package/src/checkout.ts +21 -4
- package/src/deposit-address.ts +2 -2
- package/src/generated/openapi.d.ts +9482 -0
- package/src/icon-names.ts +20 -0
- package/src/icon-svg.ts +13 -0
- package/src/icons.ts +30 -0
- package/src/index.ts +6 -2
- package/src/request.ts +7 -0
- package/src/shared/checkout-params.ts +6 -0
- package/dist/react/Checkout.d.ts +0 -43
- package/dist/react/Checkout.d.ts.map +0 -1
- package/dist/react/Checkout.js +0 -193
- package/dist/react/Checkout.js.map +0 -1
- package/dist/react/DepositAddress.d.ts +0 -32
- package/dist/react/DepositAddress.d.ts.map +0 -1
- package/dist/react/DepositAddress.js +0 -131
- package/dist/react/DepositAddress.js.map +0 -1
- package/dist/react/Field.d.ts +0 -7
- package/dist/react/Field.d.ts.map +0 -1
- package/dist/react/Field.js +0 -21
- package/dist/react/Field.js.map +0 -1
- package/dist/react/QrCode.d.ts +0 -8
- package/dist/react/QrCode.d.ts.map +0 -1
- package/dist/react/QrCode.js +0 -20
- package/dist/react/QrCode.js.map +0 -1
- package/dist/react/appearance.d.ts +0 -5
- package/dist/react/appearance.d.ts.map +0 -1
- package/dist/react/appearance.js +0 -2
- package/dist/react/appearance.js.map +0 -1
- package/dist/react/index.d.ts +0 -5
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js +0 -5
- package/dist/react/index.js.map +0 -1
- package/dist/react/useCheckout.d.ts +0 -9
- package/dist/react/useCheckout.d.ts.map +0 -1
- package/dist/react/useCheckout.js +0 -32
- package/dist/react/useCheckout.js.map +0 -1
- package/dist/server/addresses.d.ts +0 -78
- package/dist/server/addresses.d.ts.map +0 -1
- package/dist/server/addresses.js +0 -118
- package/dist/server/addresses.js.map +0 -1
- package/dist/server/index.d.ts +0 -12
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/index.js +0 -12
- package/dist/server/index.js.map +0 -1
- package/dist/server/sweeps.d.ts +0 -78
- package/dist/server/sweeps.d.ts.map +0 -1
- package/dist/server/sweeps.js +0 -117
- package/dist/server/sweeps.js.map +0 -1
- package/dist/server/webhook.d.ts +0 -61
- package/dist/server/webhook.d.ts.map +0 -1
- package/dist/server/webhook.js +0 -154
- package/dist/server/webhook.js.map +0 -1
- package/src/css.d.ts +0 -1
- package/src/react/Checkout.tsx +0 -469
- package/src/react/DepositAddress.tsx +0 -239
- package/src/react/Field.tsx +0 -46
- package/src/react/QrCode.tsx +0 -39
- package/src/react/appearance.ts +0 -4
- package/src/react/index.ts +0 -6
- package/src/react/useCheckout.ts +0 -58
- package/src/server/addresses.ts +0 -223
- package/src/server/index.ts +0 -38
- package/src/server/sweeps.ts +0 -197
- package/src/server/webhook.ts +0 -208
- package/src/styles.css +0 -76
package/dist/react/Field.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","sourceRoot":"","sources":["../../src/react/Field.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,+FAA+F;AAC/F,MAAM,UAAU,KAAK,CAAC,EACpB,KAAK,EACL,KAAK,EACL,IAAI,GAAG,KAAK,GAKb;IACC,OAAO,CACL,eAAK,SAAS,EAAC,UAAU,aACvB,uBAAK,KAAK,GAAM,EAChB,yBACE,eAAM,SAAS,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,YAAG,KAAK,GAAQ,EACvE,IAAI,KAAK,KAAK,IAAI,CACjB,KAAC,UAAU,IAAC,KAAK,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,GAAI,CAC7E,IACE,IACD,CACP,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,EAAoC;IACpE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAiB,IAAI,CAAC,CAAC;IAC3D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QACD,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;QACtD,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACb,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CACvC,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EACrB,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CACvB,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,CACL,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,SAAS,EAAC,OAAO,EAAE,OAAO,gBAAc,QAAQ,KAAK,EAAE,YACrF,4BAAgB,QAAQ,YAAE,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,GAAQ,GACvF,CACV,CAAC;AACJ,CAAC"}
|
package/dist/react/QrCode.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface QrCodeProps {
|
|
2
|
-
value: string;
|
|
3
|
-
label: string;
|
|
4
|
-
size?: number;
|
|
5
|
-
}
|
|
6
|
-
/** A QR code as an SVG path, one unit per module. */
|
|
7
|
-
export declare function QrCode({ value, label, size }: QrCodeProps): import("react").JSX.Element;
|
|
8
|
-
//# sourceMappingURL=QrCode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QrCode.d.ts","sourceRoot":"","sources":["../../src/react/QrCode.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qDAAqD;AACrD,wBAAgB,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAU,EAAE,EAAE,WAAW,+BA4B/D"}
|
package/dist/react/QrCode.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { encode } from "uqr";
|
|
4
|
-
/** A QR code as an SVG path, one unit per module. */
|
|
5
|
-
export function QrCode({ value, label, size = 208 }) {
|
|
6
|
-
const { path, width } = useMemo(() => {
|
|
7
|
-
const { data, size: modules } = encode(value, { ecc: "M", border: 2 });
|
|
8
|
-
let d = "";
|
|
9
|
-
data.forEach((row, y) => {
|
|
10
|
-
row.forEach((dark, x) => {
|
|
11
|
-
if (dark) {
|
|
12
|
-
d += `M${x} ${y}h1v1h-1z`;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
return { path: d, width: modules };
|
|
17
|
-
}, [value]);
|
|
18
|
-
return (_jsxs("svg", { className: "pp-qr", role: "img", "aria-label": label, width: size, height: size, viewBox: `0 0 ${width} ${width}`, shapeRendering: "crispEdges", children: [_jsx("rect", { width: width, height: width, fill: "#fff" }), _jsx("path", { d: path, fill: "#000" })] }));
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=QrCode.js.map
|
package/dist/react/QrCode.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QrCode.js","sourceRoot":"","sources":["../../src/react/QrCode.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAQ7B,qDAAqD;AACrD,MAAM,UAAU,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,GAAG,GAAG,EAAe;IAC9D,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE;QACnC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;QACvE,IAAI,CAAC,GAAG,EAAE,CAAC;QACX,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;YACtB,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;gBACtB,IAAI,IAAI,EAAE,CAAC;oBACT,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;gBAC5B,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IACrC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CACL,eACE,SAAS,EAAC,OAAO,EACjB,IAAI,EAAC,KAAK,gBACE,KAAK,EACjB,KAAK,EAAE,IAAI,EACX,MAAM,EAAE,IAAI,EACZ,OAAO,EAAE,OAAO,KAAK,IAAI,KAAK,EAAE,EAChC,cAAc,EAAC,YAAY,aAE3B,eAAM,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAC,MAAM,GAAG,EACjD,eAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,GAAG,IACzB,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appearance.d.ts","sourceRoot":"","sources":["../../src/react/appearance.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B"}
|
package/dist/react/appearance.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appearance.js","sourceRoot":"","sources":["../../src/react/appearance.ts"],"names":[],"mappings":""}
|
package/dist/react/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { Checkout, type CheckoutProps } from "./Checkout.js";
|
|
2
|
-
export { DepositAddress, type DepositAddressProps } from "./DepositAddress.js";
|
|
3
|
-
export { useCheckout, type UseCheckoutOptions, type UseCheckoutResult } from "./useCheckout.js";
|
|
4
|
-
export type { Appearance } from "./appearance.js";
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAChG,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/react/index.js
DELETED
package/dist/react/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAsB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,cAAc,EAA4B,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAmD,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type CheckoutOptions, type CheckoutState } from "../checkout.js";
|
|
2
|
-
export type UseCheckoutOptions = Pick<CheckoutOptions, "clientSecret" | "expectedAddress" | "apiBase" | "pollInterval" | "signal" | "requestTimeout">;
|
|
3
|
-
export interface UseCheckoutResult extends CheckoutState {
|
|
4
|
-
/** Reads the quote now, for example right after the wallet broadcast the payment. */
|
|
5
|
-
refresh: () => void;
|
|
6
|
-
}
|
|
7
|
-
/** Follows a quote's public view for as long as the component is mounted. */
|
|
8
|
-
export declare function useCheckout({ clientSecret, expectedAddress, apiBase, pollInterval, signal, requestTimeout, }: UseCheckoutOptions): UseCheckoutResult;
|
|
9
|
-
//# sourceMappingURL=useCheckout.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCheckout.d.ts","sourceRoot":"","sources":["../../src/react/useCheckout.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,eAAe,EAEpB,KAAK,aAAa,EACnB,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,eAAe,EACf,cAAc,GAAG,iBAAiB,GAAG,SAAS,GAAG,cAAc,GAAG,QAAQ,GAAG,gBAAgB,CAC9F,CAAC;AAEF,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,qFAAqF;IACrF,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAID,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,EAC1B,YAAY,EACZ,eAAe,EACf,OAAO,EACP,YAAY,EACZ,MAAM,EACN,cAAc,GACf,EAAE,kBAAkB,GAAG,iBAAiB,CA6BxC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
-
import { createCheckout, } from "../checkout.js";
|
|
3
|
-
const LOADING = { status: "loading", quote: null, error: null };
|
|
4
|
-
/** Follows a quote's public view for as long as the component is mounted. */
|
|
5
|
-
export function useCheckout({ clientSecret, expectedAddress, apiBase, pollInterval, signal, requestTimeout, }) {
|
|
6
|
-
const [current, setCurrent] = useState({ key: "", state: LOADING });
|
|
7
|
-
const checkout = useRef(null);
|
|
8
|
-
const key = `${apiBase} ${clientSecret} ${expectedAddress}`;
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
const instance = createCheckout({
|
|
11
|
-
clientSecret,
|
|
12
|
-
expectedAddress,
|
|
13
|
-
apiBase,
|
|
14
|
-
...(pollInterval === undefined ? {} : { pollInterval }),
|
|
15
|
-
...(signal === undefined ? {} : { signal }),
|
|
16
|
-
...(requestTimeout === undefined ? {} : { requestTimeout }),
|
|
17
|
-
});
|
|
18
|
-
checkout.current = instance;
|
|
19
|
-
const unsubscribe = instance.subscribe((state) => setCurrent({ key, state }));
|
|
20
|
-
return () => {
|
|
21
|
-
unsubscribe();
|
|
22
|
-
instance.destroy();
|
|
23
|
-
checkout.current = null;
|
|
24
|
-
};
|
|
25
|
-
}, [key, clientSecret, expectedAddress, apiBase, pollInterval, signal, requestTimeout]);
|
|
26
|
-
const refresh = useCallback(() => {
|
|
27
|
-
void checkout.current?.refresh();
|
|
28
|
-
}, []);
|
|
29
|
-
// A new client secret starts from `loading`, not from the previous quote's state.
|
|
30
|
-
return { ...(current.key === key ? current.state : LOADING), refresh };
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=useCheckout.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCheckout.js","sourceRoot":"","sources":["../../src/react/useCheckout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EACL,cAAc,GAIf,MAAM,gBAAgB,CAAC;AAYxB,MAAM,OAAO,GAAkB,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAE/E,6EAA6E;AAC7E,MAAM,UAAU,WAAW,CAAC,EAC1B,YAAY,EACZ,eAAe,EACf,OAAO,EACP,YAAY,EACZ,MAAM,EACN,cAAc,GACK;IACnB,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IACpE,MAAM,QAAQ,GAAG,MAAM,CAAyB,IAAI,CAAC,CAAC;IACtD,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E,OAAO,EAAE,CAAC;AACzE,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { type Address, type Hex } from "viem";
|
|
2
|
-
/**
|
|
3
|
-
* The forwarder `factory` deploys for `treasury` and `salt`: OpenZeppelin 5.x
|
|
4
|
-
* `Clones.predictDeterministicAddressWithImmutableArgs` with `abi.encodePacked(treasury)`, so the
|
|
5
|
-
* address commits to the factory, the implementation, the treasury, and the salt.
|
|
6
|
-
*/
|
|
7
|
-
export declare function forwarderAddress(factory: string, implementation: string, treasury: string, salt: Hex): Address;
|
|
8
|
-
/** `keccak256(abi.encode(account, client_reference_id, "quote", quote_id))`: a quote's salt. */
|
|
9
|
-
export declare function quoteSalt(account: string, clientReferenceId: string, quoteId: string): Hex;
|
|
10
|
-
/**
|
|
11
|
-
* `keccak256(abi.encode(account, livemode, client_reference_id, "deposit_address", version))`:
|
|
12
|
-
* a deposit address's salt, the same on every chain.
|
|
13
|
-
*/
|
|
14
|
-
export declare function depositAddressSalt(account: string, livemode: boolean, clientReferenceId: string, version: number | bigint): Hex;
|
|
15
|
-
export interface Forwarder {
|
|
16
|
-
factory: string;
|
|
17
|
-
implementation: string;
|
|
18
|
-
}
|
|
19
|
-
/** The address of a quote over `treasury`, which you pin yourself (see `verifyQuoteAddress`). */
|
|
20
|
-
export declare function quoteAddress(forwarder: Forwarder, quote: {
|
|
21
|
-
client_reference_id: string;
|
|
22
|
-
id: string;
|
|
23
|
-
}, treasury: string, account: string): Address;
|
|
24
|
-
/** A deposit address on the network whose treasury is `treasury`, which you pin yourself. */
|
|
25
|
-
export declare function depositAddress(forwarder: Forwarder, address: {
|
|
26
|
-
livemode: boolean;
|
|
27
|
-
client_reference_id: string;
|
|
28
|
-
version: number;
|
|
29
|
-
}, treasury: string, account: string): Address;
|
|
30
|
-
/** An address the service returned is not the one your pins derive: show nothing to pay. */
|
|
31
|
-
export declare class AddressMismatchError extends Error {
|
|
32
|
-
readonly name = "AddressMismatchError";
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* What every address is recomputed from, configured on your server and never read from the
|
|
36
|
-
* service: your account id (`acct_…`), the forwarder `factory` and `implementation` of the
|
|
37
|
-
* attested deployment, and `treasuries`, your own treasury per chain id as you proved it. A
|
|
38
|
-
* compromised service could return another treasury with the address that really derives from
|
|
39
|
-
* it, so the response's `treasury` is never trusted.
|
|
40
|
-
*
|
|
41
|
-
* Live mode requires `treasuries`: without the chain's treasury the check fails closed. In test
|
|
42
|
-
* mode an unpinned chain falls back to the response's treasury with a console warning.
|
|
43
|
-
*/
|
|
44
|
-
export interface AddressPins extends Forwarder {
|
|
45
|
-
account: string;
|
|
46
|
-
treasuries?: Readonly<Record<number, string>> | undefined;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Recomputes an open quote's address from your pins and returns it, the `expectedAddress` to
|
|
50
|
-
* pass to `<Checkout>`. Throws `AddressMismatchError` unless the quote names your pinned
|
|
51
|
-
* treasury of its chain and its address derives from it; in live mode also when the chain has no
|
|
52
|
-
* pinned treasury.
|
|
53
|
-
*/
|
|
54
|
-
export declare function verifyQuoteAddress(pins: AddressPins, quote: {
|
|
55
|
-
id: string;
|
|
56
|
-
livemode: boolean;
|
|
57
|
-
chain_id: number;
|
|
58
|
-
treasury: string;
|
|
59
|
-
address: string;
|
|
60
|
-
client_reference_id: string;
|
|
61
|
-
}): Address;
|
|
62
|
-
/**
|
|
63
|
-
* Recomputes every network of an active deposit address from your pins and returns the address,
|
|
64
|
-
* the same on every network. Throws `AddressMismatchError` as `verifyQuoteAddress` does, for any
|
|
65
|
-
* network.
|
|
66
|
-
*/
|
|
67
|
-
export declare function verifyDepositAddress(pins: AddressPins, address: {
|
|
68
|
-
id: string;
|
|
69
|
-
livemode: boolean;
|
|
70
|
-
client_reference_id: string;
|
|
71
|
-
version: number;
|
|
72
|
-
networks: readonly {
|
|
73
|
-
chain_id: number;
|
|
74
|
-
treasury: string;
|
|
75
|
-
address: string;
|
|
76
|
-
}[];
|
|
77
|
-
}): Address;
|
|
78
|
-
//# sourceMappingURL=addresses.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../../src/server/addresses.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,OAAO,EACZ,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AAEd;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,GAAG,GACR,OAAO,CAgBT;AAED,gGAAgG;AAChG,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CAO1F;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,OAAO,EACjB,iBAAiB,EAAE,MAAM,EACzB,OAAO,EAAE,MAAM,GAAG,MAAM,GACvB,GAAG,CAaL;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,iGAAiG;AACjG,wBAAgB,YAAY,CAC1B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE;IAAE,mBAAmB,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EAClD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAOT;AAED,6FAA6F;AAC7F,wBAAgB,cAAc,CAC5B,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAC5E,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAOT;AAED,4FAA4F;AAC5F,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,SAAkB,IAAI,0BAA0B;CACjD;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;CAC3D;AAwCD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE;IACL,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,GACA,OAAO,CAST;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE;IACP,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,OAAO,CAAC;IAClB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,SAAS;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC9E,GACA,OAAO,CAgBT"}
|
package/dist/server/addresses.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { encodeAbiParameters, getAddress, getContractAddress, keccak256, concat, } from "viem";
|
|
2
|
-
/**
|
|
3
|
-
* The forwarder `factory` deploys for `treasury` and `salt`: OpenZeppelin 5.x
|
|
4
|
-
* `Clones.predictDeterministicAddressWithImmutableArgs` with `abi.encodePacked(treasury)`, so the
|
|
5
|
-
* address commits to the factory, the implementation, the treasury, and the salt.
|
|
6
|
-
*/
|
|
7
|
-
export function forwarderAddress(factory, implementation, treasury, salt) {
|
|
8
|
-
const initCode = concat([
|
|
9
|
-
"0x61",
|
|
10
|
-
"0x0041", // runtime length: the 45-byte proxy and the 20 treasury bytes
|
|
11
|
-
"0x3d81600a3d39f3",
|
|
12
|
-
"0x363d3d373d3d3d363d73",
|
|
13
|
-
getAddress(implementation),
|
|
14
|
-
"0x5af43d82803e903d91602b57fd5bf3",
|
|
15
|
-
getAddress(treasury),
|
|
16
|
-
]);
|
|
17
|
-
return getContractAddress({
|
|
18
|
-
opcode: "CREATE2",
|
|
19
|
-
from: getAddress(factory),
|
|
20
|
-
salt,
|
|
21
|
-
bytecodeHash: keccak256(initCode),
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
/** `keccak256(abi.encode(account, client_reference_id, "quote", quote_id))`: a quote's salt. */
|
|
25
|
-
export function quoteSalt(account, clientReferenceId, quoteId) {
|
|
26
|
-
return keccak256(encodeAbiParameters([{ type: "string" }, { type: "string" }, { type: "string" }, { type: "string" }], [account, clientReferenceId, "quote", quoteId]));
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* `keccak256(abi.encode(account, livemode, client_reference_id, "deposit_address", version))`:
|
|
30
|
-
* a deposit address's salt, the same on every chain.
|
|
31
|
-
*/
|
|
32
|
-
export function depositAddressSalt(account, livemode, clientReferenceId, version) {
|
|
33
|
-
return keccak256(encodeAbiParameters([
|
|
34
|
-
{ type: "string" },
|
|
35
|
-
{ type: "bool" },
|
|
36
|
-
{ type: "string" },
|
|
37
|
-
{ type: "string" },
|
|
38
|
-
{ type: "uint256" },
|
|
39
|
-
], [account, livemode, clientReferenceId, "deposit_address", BigInt(version)]));
|
|
40
|
-
}
|
|
41
|
-
/** The address of a quote over `treasury`, which you pin yourself (see `verifyQuoteAddress`). */
|
|
42
|
-
export function quoteAddress(forwarder, quote, treasury, account) {
|
|
43
|
-
return forwarderAddress(forwarder.factory, forwarder.implementation, treasury, quoteSalt(account, quote.client_reference_id, quote.id));
|
|
44
|
-
}
|
|
45
|
-
/** A deposit address on the network whose treasury is `treasury`, which you pin yourself. */
|
|
46
|
-
export function depositAddress(forwarder, address, treasury, account) {
|
|
47
|
-
return forwarderAddress(forwarder.factory, forwarder.implementation, treasury, depositAddressSalt(account, address.livemode, address.client_reference_id, address.version));
|
|
48
|
-
}
|
|
49
|
-
/** An address the service returned is not the one your pins derive: show nothing to pay. */
|
|
50
|
-
export class AddressMismatchError extends Error {
|
|
51
|
-
name = "AddressMismatchError";
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* The treasury an address on `chainId` must pay: the pinned one, which the response must name.
|
|
55
|
-
*/
|
|
56
|
-
function pinnedTreasury(pins, livemode, chainId, treasury, where) {
|
|
57
|
-
const pinned = pins.treasuries?.[chainId];
|
|
58
|
-
if (pinned === undefined) {
|
|
59
|
-
if (livemode) {
|
|
60
|
-
throw new AddressMismatchError(`${where}: live mode requires your pinned treasury of chain ${chainId}`);
|
|
61
|
-
}
|
|
62
|
-
console.warn(`${where}: no pinned treasury of chain ${chainId}; the service's ${treasury} is trusted (test mode only)`);
|
|
63
|
-
return treasury;
|
|
64
|
-
}
|
|
65
|
-
if (!sameAddress(pinned, treasury)) {
|
|
66
|
-
throw new AddressMismatchError(`${where} pays a treasury that is not the pinned one`);
|
|
67
|
-
}
|
|
68
|
-
return pinned;
|
|
69
|
-
}
|
|
70
|
-
function requirePins(pins, where) {
|
|
71
|
-
for (const field of ["account", "factory", "implementation"]) {
|
|
72
|
-
if (typeof pins[field] !== "string" || pins[field] === "") {
|
|
73
|
-
throw new AddressMismatchError(`${where}: the pinned ${field} is missing`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function sameAddress(a, b) {
|
|
78
|
-
return a.toLowerCase() === b.toLowerCase();
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Recomputes an open quote's address from your pins and returns it, the `expectedAddress` to
|
|
82
|
-
* pass to `<Checkout>`. Throws `AddressMismatchError` unless the quote names your pinned
|
|
83
|
-
* treasury of its chain and its address derives from it; in live mode also when the chain has no
|
|
84
|
-
* pinned treasury.
|
|
85
|
-
*/
|
|
86
|
-
export function verifyQuoteAddress(pins, quote) {
|
|
87
|
-
const where = `quote ${quote.id}`;
|
|
88
|
-
requirePins(pins, where);
|
|
89
|
-
const treasury = pinnedTreasury(pins, quote.livemode, quote.chain_id, quote.treasury, where);
|
|
90
|
-
const derived = quoteAddress(pins, quote, treasury, pins.account);
|
|
91
|
-
if (!sameAddress(derived, quote.address)) {
|
|
92
|
-
throw new AddressMismatchError(`${where} has an address the account cannot derive`);
|
|
93
|
-
}
|
|
94
|
-
return derived;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Recomputes every network of an active deposit address from your pins and returns the address,
|
|
98
|
-
* the same on every network. Throws `AddressMismatchError` as `verifyQuoteAddress` does, for any
|
|
99
|
-
* network.
|
|
100
|
-
*/
|
|
101
|
-
export function verifyDepositAddress(pins, address) {
|
|
102
|
-
requirePins(pins, `deposit address ${address.id}`);
|
|
103
|
-
let first;
|
|
104
|
-
for (const network of address.networks) {
|
|
105
|
-
const where = `deposit address ${address.id} on chain ${network.chain_id}`;
|
|
106
|
-
const treasury = pinnedTreasury(pins, address.livemode, network.chain_id, network.treasury, where);
|
|
107
|
-
const derived = depositAddress(pins, address, treasury, pins.account);
|
|
108
|
-
if (!sameAddress(derived, network.address)) {
|
|
109
|
-
throw new AddressMismatchError(`${where} is not one the account can derive`);
|
|
110
|
-
}
|
|
111
|
-
first ??= derived;
|
|
112
|
-
}
|
|
113
|
-
if (first === undefined) {
|
|
114
|
-
throw new AddressMismatchError(`deposit address ${address.id} has no network`);
|
|
115
|
-
}
|
|
116
|
-
return first;
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=addresses.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addresses.js","sourceRoot":"","sources":["../../src/server/addresses.ts"],"names":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,GAAG,KAAK,2CAA2C,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAAiB,EACjB,OAMC;IAED,WAAW,CAAC,IAAI,EAAE,mBAAmB,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IACnD,IAAI,KAA0B,CAAC;IAC/B,KAAK,MAAM,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,mBAAmB,OAAO,CAAC,EAAE,aAAa,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC3E,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACnG,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACtE,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,oBAAoB,CAAC,GAAG,KAAK,oCAAoC,CAAC,CAAC;QAC/E,CAAC;QACD,KAAK,KAAK,OAAO,CAAC;IACpB,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,oBAAoB,CAAC,mBAAmB,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/server/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server-side helpers of `@phala/pay`. Nothing here needs or takes an API key: webhook
|
|
3
|
-
* verification uses your account's public webhook key, and the address and sweep helpers run
|
|
4
|
-
* offline. Call the API itself from your backend with a restricted key (the Python SDK, or any
|
|
5
|
-
* HTTP client with `Authorization: Bearer ppay_rk_…`); never ship a key to a browser. Recompute
|
|
6
|
-
* every address with `verifyQuoteAddress` or `verifyDepositAddress` from the pins you configure
|
|
7
|
-
* yourself before you show it.
|
|
8
|
-
*/
|
|
9
|
-
export { WebhookSignatureError, constructEvent, type ConstructEventOptions, type WebhookEvent, } from "./webhook.js";
|
|
10
|
-
export { AddressMismatchError, depositAddress, depositAddressSalt, forwarderAddress, quoteSalt, quoteAddress, verifyDepositAddress, verifyQuoteAddress, type AddressPins, type Forwarder, } from "./addresses.js";
|
|
11
|
-
export { batchChecksum, flushTransaction, flushTransactions, safeBatch, type BatchFile, type BatchFileMeta, type BatchTransaction, type Call, type ForwarderObject, type SafeBatchOptions, } from "./sweeps.js";
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,YAAY,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,KAAK,WAAW,EAChB,KAAK,SAAS,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,IAAI,EACT,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC"}
|
package/dist/server/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server-side helpers of `@phala/pay`. Nothing here needs or takes an API key: webhook
|
|
3
|
-
* verification uses your account's public webhook key, and the address and sweep helpers run
|
|
4
|
-
* offline. Call the API itself from your backend with a restricted key (the Python SDK, or any
|
|
5
|
-
* HTTP client with `Authorization: Bearer ppay_rk_…`); never ship a key to a browser. Recompute
|
|
6
|
-
* every address with `verifyQuoteAddress` or `verifyDepositAddress` from the pins you configure
|
|
7
|
-
* yourself before you show it.
|
|
8
|
-
*/
|
|
9
|
-
export { WebhookSignatureError, constructEvent, } from "./webhook.js";
|
|
10
|
-
export { AddressMismatchError, depositAddress, depositAddressSalt, forwarderAddress, quoteSalt, quoteAddress, verifyDepositAddress, verifyQuoteAddress, } from "./addresses.js";
|
|
11
|
-
export { batchChecksum, flushTransaction, flushTransactions, safeBatch, } from "./sweeps.js";
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
package/dist/server/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,qBAAqB,EACrB,cAAc,GAGf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,GAGnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,GAOV,MAAM,aAAa,CAAC"}
|
package/dist/server/sweeps.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { type Address, type Hex } from "viem";
|
|
2
|
-
/** A contract call as a wallet or the Safe Transaction Builder takes it. */
|
|
3
|
-
export interface Call {
|
|
4
|
-
to: Address;
|
|
5
|
-
data: Hex;
|
|
6
|
-
/** Native value in wei, a decimal string: `"0"` for a flush. */
|
|
7
|
-
value: string;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* `factory.flush(treasury, salts, token)`, encoded offline from the exported forwarders
|
|
11
|
-
* (`GET /v1/forwarders`): every listed forwarder's whole balance of `token` moves to `treasury`,
|
|
12
|
-
* the only address it can pay. Anyone may send it; the sender pays the gas.
|
|
13
|
-
*/
|
|
14
|
-
export declare function flushTransaction(factory: string, treasury: string, salts: readonly Hex[], token: string): Call;
|
|
15
|
-
/** A forwarder as `GET /v1/forwarders` returns it. */
|
|
16
|
-
export interface ForwarderObject {
|
|
17
|
-
chain_id: number;
|
|
18
|
-
factory: string;
|
|
19
|
-
treasury: string;
|
|
20
|
-
salt: string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Groups forwarders of one chain, such as `GET /v1/forwarders?sweepable=<token>` lists, into
|
|
24
|
-
* `flushTransaction` calls: one per factory and treasury, of at most `maxSalts` forwarders.
|
|
25
|
-
*/
|
|
26
|
-
export declare function flushTransactions(forwarders: Iterable<ForwarderObject>, token: string, maxSalts?: number): Call[];
|
|
27
|
-
/**
|
|
28
|
-
* The Safe Transaction Builder's batch file, its `BatchFile` type
|
|
29
|
-
* (safe-global/safe-react-apps, `apps/tx-builder/src/typings/models.ts` at commit
|
|
30
|
-
* e8cccfb9a1042fa2954087988bae59c3b8c81780).
|
|
31
|
-
*/
|
|
32
|
-
export interface BatchFile {
|
|
33
|
-
version: string;
|
|
34
|
-
chainId: string;
|
|
35
|
-
createdAt: number;
|
|
36
|
-
meta: BatchFileMeta;
|
|
37
|
-
transactions: BatchTransaction[];
|
|
38
|
-
}
|
|
39
|
-
export interface BatchFileMeta {
|
|
40
|
-
txBuilderVersion?: string;
|
|
41
|
-
checksum?: string;
|
|
42
|
-
createdFromSafeAddress?: string;
|
|
43
|
-
createdFromOwnerAddress?: string;
|
|
44
|
-
name: string;
|
|
45
|
-
description?: string;
|
|
46
|
-
}
|
|
47
|
-
export interface BatchTransaction {
|
|
48
|
-
to: string;
|
|
49
|
-
value: string;
|
|
50
|
-
data?: string;
|
|
51
|
-
contractMethod?: {
|
|
52
|
-
inputs: unknown[];
|
|
53
|
-
name: string;
|
|
54
|
-
payable: boolean;
|
|
55
|
-
};
|
|
56
|
-
contractInputsValues?: {
|
|
57
|
-
[key: string]: string;
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
export interface SafeBatchOptions {
|
|
61
|
-
name?: string;
|
|
62
|
-
description?: string;
|
|
63
|
-
/** Milliseconds; now by default. */
|
|
64
|
-
createdAt?: number;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* A Transaction Builder batch file of `calls` for the Safe `safe` on `chainId`, with the app's
|
|
68
|
-
* `meta.checksum`, so it imports without the "modified since it was generated" warning. A Safe
|
|
69
|
-
* owner imports it in Safe{Wallet} > Apps > Transaction Builder; the owners sign and execute it.
|
|
70
|
-
*/
|
|
71
|
-
export declare function safeBatch(chainId: number, safe: string, calls: readonly Call[], options?: SafeBatchOptions): BatchFile;
|
|
72
|
-
/**
|
|
73
|
-
* The Transaction Builder's `meta.checksum` (`apps/tx-builder/src/lib/checksum.ts`): Keccak-256
|
|
74
|
-
* of its key-sorted serialization with `meta.name` set to `null`, over the file without its
|
|
75
|
-
* checksum, as the app's `validateChecksum` recomputes it.
|
|
76
|
-
*/
|
|
77
|
-
export declare function batchChecksum(batch: BatchFile): Hex;
|
|
78
|
-
//# sourceMappingURL=sweeps.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sweeps.d.ts","sourceRoot":"","sources":["../../src/server/sweeps.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,OAAO,EACZ,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AAgBd,4EAA4E;AAC5E,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,EAAE,GAAG,CAAC;IACV,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,E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AE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,OAAO,GAAE,gBAAqB,GAC7B,SAAS,CAsBX;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,CAInD"}
|
package/dist/server/sweeps.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { encodeFunctionData, getAddress, isHex, keccak256, stringToBytes, } from "viem";
|
|
2
|
-
const FLUSH_ABI = [
|
|
3
|
-
{
|
|
4
|
-
type: "function",
|
|
5
|
-
name: "flush",
|
|
6
|
-
stateMutability: "nonpayable",
|
|
7
|
-
inputs: [
|
|
8
|
-
{ name: "treasury", type: "address" },
|
|
9
|
-
{ name: "salts", type: "bytes32[]" },
|
|
10
|
-
{ name: "token", type: "address" },
|
|
11
|
-
],
|
|
12
|
-
outputs: [],
|
|
13
|
-
},
|
|
14
|
-
];
|
|
15
|
-
/**
|
|
16
|
-
* `factory.flush(treasury, salts, token)`, encoded offline from the exported forwarders
|
|
17
|
-
* (`GET /v1/forwarders`): every listed forwarder's whole balance of `token` moves to `treasury`,
|
|
18
|
-
* the only address it can pay. Anyone may send it; the sender pays the gas.
|
|
19
|
-
*/
|
|
20
|
-
export function flushTransaction(factory, treasury, salts, token) {
|
|
21
|
-
if (salts.length === 0) {
|
|
22
|
-
throw new TypeError("flush needs at least one salt");
|
|
23
|
-
}
|
|
24
|
-
if (!salts.every((salt) => isHex(salt) && salt.length === 66)) {
|
|
25
|
-
throw new TypeError("a salt is 32 bytes of hex");
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
to: getAddress(factory),
|
|
29
|
-
data: encodeFunctionData({
|
|
30
|
-
abi: FLUSH_ABI,
|
|
31
|
-
functionName: "flush",
|
|
32
|
-
args: [getAddress(treasury), salts, getAddress(token)],
|
|
33
|
-
}),
|
|
34
|
-
value: "0",
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Groups forwarders of one chain, such as `GET /v1/forwarders?sweepable=<token>` lists, into
|
|
39
|
-
* `flushTransaction` calls: one per factory and treasury, of at most `maxSalts` forwarders.
|
|
40
|
-
*/
|
|
41
|
-
export function flushTransactions(forwarders, token, maxSalts = 200) {
|
|
42
|
-
const groups = new Map();
|
|
43
|
-
const chains = new Set();
|
|
44
|
-
for (const forwarder of forwarders) {
|
|
45
|
-
chains.add(forwarder.chain_id);
|
|
46
|
-
const factory = getAddress(forwarder.factory);
|
|
47
|
-
const treasury = getAddress(forwarder.treasury);
|
|
48
|
-
const key = `${factory}:${treasury}`;
|
|
49
|
-
const group = groups.get(key) ?? { factory, treasury, salts: [] };
|
|
50
|
-
if (!isHex(forwarder.salt)) {
|
|
51
|
-
throw new TypeError("a salt is 32 bytes of hex");
|
|
52
|
-
}
|
|
53
|
-
group.salts.push(forwarder.salt);
|
|
54
|
-
groups.set(key, group);
|
|
55
|
-
}
|
|
56
|
-
if (chains.size > 1) {
|
|
57
|
-
throw new TypeError("a batch of flush calls is for one chain");
|
|
58
|
-
}
|
|
59
|
-
const calls = [];
|
|
60
|
-
for (const { factory, treasury, salts } of groups.values()) {
|
|
61
|
-
for (let start = 0; start < salts.length; start += maxSalts) {
|
|
62
|
-
calls.push(flushTransaction(factory, treasury, salts.slice(start, start + maxSalts), token));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return calls;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* A Transaction Builder batch file of `calls` for the Safe `safe` on `chainId`, with the app's
|
|
69
|
-
* `meta.checksum`, so it imports without the "modified since it was generated" warning. A Safe
|
|
70
|
-
* owner imports it in Safe{Wallet} > Apps > Transaction Builder; the owners sign and execute it.
|
|
71
|
-
*/
|
|
72
|
-
export function safeBatch(chainId, safe, calls, options = {}) {
|
|
73
|
-
if (calls.length === 0) {
|
|
74
|
-
throw new TypeError("a batch needs at least one call");
|
|
75
|
-
}
|
|
76
|
-
const batch = {
|
|
77
|
-
version: "1.0",
|
|
78
|
-
chainId: String(chainId),
|
|
79
|
-
createdAt: options.createdAt ?? Date.now(),
|
|
80
|
-
meta: {
|
|
81
|
-
name: options.name ?? "Phala Pay sweep",
|
|
82
|
-
description: options.description ?? "",
|
|
83
|
-
createdFromSafeAddress: getAddress(safe),
|
|
84
|
-
},
|
|
85
|
-
transactions: calls.map((call) => {
|
|
86
|
-
if (!/^\d+$/.test(call.value) || !isHex(call.data)) {
|
|
87
|
-
throw new TypeError("a call needs hex data and a decimal value");
|
|
88
|
-
}
|
|
89
|
-
return { to: getAddress(call.to), value: call.value, data: call.data };
|
|
90
|
-
}),
|
|
91
|
-
};
|
|
92
|
-
batch.meta.checksum = batchChecksum(batch);
|
|
93
|
-
return batch;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* The Transaction Builder's `meta.checksum` (`apps/tx-builder/src/lib/checksum.ts`): Keccak-256
|
|
97
|
-
* of its key-sorted serialization with `meta.name` set to `null`, over the file without its
|
|
98
|
-
* checksum, as the app's `validateChecksum` recomputes it.
|
|
99
|
-
*/
|
|
100
|
-
export function batchChecksum(batch) {
|
|
101
|
-
const meta = { ...batch.meta, name: null };
|
|
102
|
-
delete meta["checksum"];
|
|
103
|
-
return keccak256(stringToBytes(serialize({ ...batch, meta })));
|
|
104
|
-
}
|
|
105
|
-
/** The app's `serializeJSONObject`. */
|
|
106
|
-
function serialize(value) {
|
|
107
|
-
if (Array.isArray(value)) {
|
|
108
|
-
return `[${value.map(serialize).join(",")}]`;
|
|
109
|
-
}
|
|
110
|
-
if (typeof value === "object" && value !== null) {
|
|
111
|
-
const record = value;
|
|
112
|
-
const keys = Object.keys(record).sort();
|
|
113
|
-
return `{${JSON.stringify(keys)}${keys.map((key) => `${serialize(record[key])},`).join("")}}`;
|
|
114
|
-
}
|
|
115
|
-
return JSON.stringify(value === undefined ? null : value);
|
|
116
|
-
}
|
|
117
|
-
//# sourceMappingURL=sweeps.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sweeps.js","sourceRoot":"","sources":["../../src/server/sweeps.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,KAAK,EACL,SAAS,EACT,aAAa,GAGd,MAAM,MAAM,CAAC;AAEd,MAAM,SAAS,GAAG;IAChB;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,OAAO;QACb,eAAe,EAAE,YAAY;QAC7B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;YACrC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE;YACpC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;SACnC;QACD,OAAO,EAAE,EAAE;KACZ;CACO,CAAC;AAUX;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAe,EACf,QAAgB,EAChB,KAAqB,EACrB,KAAa;IAEb,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,SAAS,CAAC,+BAA+B,CAAC,CAAC;IACvD,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,EAAE,CAAC,EAAE,CAAC;QAC9D,MAAM,IAAI,SAAS,CAAC,2BAA2B,CAAC,CAAC;IACnD,CAAC;IACD,OAAO;QACL,EAAE,EAAE,UAAU,CAAC,OAAO,CAAC;QACvB,IAAI,EAAE,kBAAkB,CAAC;YACvB,GAAG,EAAE,SAAS;YACd,YAAY,EA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