@daimo/pay-common 1.19.11 → 2.0.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 +9 -0
- package/index.js +1 -0
- package/package.json +5 -27
- package/LICENSE +0 -26
- package/dist/assert.d.ts +0 -5
- package/dist/assert.js +0 -31
- package/dist/assert.js.map +0 -1
- package/dist/chain.d.ts +0 -43
- package/dist/chain.js +0 -222
- package/dist/chain.js.map +0 -1
- package/dist/daimoPay.d.ts +0 -615
- package/dist/daimoPay.js +0 -309
- package/dist/daimoPay.js.map +0 -1
- package/dist/debug.d.ts +0 -4
- package/dist/debug.js +0 -25
- package/dist/debug.js.map +0 -1
- package/dist/format.d.ts +0 -15
- package/dist/format.js +0 -40
- package/dist/format.js.map +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -25
- package/dist/index.js.map +0 -1
- package/dist/primitiveTypes.d.ts +0 -10
- package/dist/primitiveTypes.js +0 -17
- package/dist/primitiveTypes.js.map +0 -1
- package/dist/token.d.ts +0 -144
- package/dist/token.js +0 -918
- package/dist/token.js.map +0 -1
- package/dist/try.d.ts +0 -3
- package/dist/try.js +0 -31
- package/dist/try.js.map +0 -1
- package/src/assert.ts +0 -29
- package/src/chain.ts +0 -247
- package/src/daimoPay.ts +0 -761
- package/src/debug.ts +0 -24
- package/src/format.ts +0 -35
- package/src/index.ts +0 -8
- package/src/primitiveTypes.ts +0 -26
- package/src/token.ts +0 -1110
- package/src/try.ts +0 -25
- package/tsconfig.json +0 -12
package/src/debug.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { formatUnits } from "viem";
|
|
2
|
-
import { getChainName } from "./chain";
|
|
3
|
-
import { DaimoPayTokenAmount } from "./daimoPay";
|
|
4
|
-
|
|
5
|
-
/** Return compact JSON, 10000 chars max. Never throws. */
|
|
6
|
-
export function debugJson(obj: any) {
|
|
7
|
-
try {
|
|
8
|
-
let serialized = JSON.stringify(obj, (_, value) =>
|
|
9
|
-
typeof value === "bigint" ? value.toString() : value,
|
|
10
|
-
);
|
|
11
|
-
if (typeof serialized !== "string") {
|
|
12
|
-
serialized = "" + obj;
|
|
13
|
-
}
|
|
14
|
-
return serialized.slice(0, 10000);
|
|
15
|
-
} catch (e: any) {
|
|
16
|
-
return `<JSON error: ${e.message}>`;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function debugDPTA(dpta: DaimoPayTokenAmount) {
|
|
21
|
-
const strUnits = formatUnits(BigInt(dpta.amount), dpta.token.decimals);
|
|
22
|
-
const chainName = getChainName(dpta.token.chainId);
|
|
23
|
-
return `${strUnits} ${dpta.token.symbol} / ${dpta.usd.toFixed(2)} on ${chainName}`;
|
|
24
|
-
}
|
package/src/format.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Contract an Ethereum address to a shorter string.
|
|
3
|
-
*
|
|
4
|
-
* Example:
|
|
5
|
-
* 0x1234567890123456789012345678901234567890
|
|
6
|
-
* becomes
|
|
7
|
-
* 0x1234…7890
|
|
8
|
-
*/
|
|
9
|
-
export function getAddressContraction(address: string, length = 4): string {
|
|
10
|
-
return address.slice(0, 2 + length) + "…" + address.slice(-length);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** Convert a JS Date object to a UNIX timestamp. */
|
|
14
|
-
export function dateToUnix(d: Date): number {
|
|
15
|
-
return Math.floor(d.getTime() / 1000);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** Convert a UNIX timestamp to a JS Date object. */
|
|
19
|
-
export function unixToDate(unix: number): Date {
|
|
20
|
-
return new Date(unix * 1000);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** Returns a time like "Dec 11, 2:46 PM" */
|
|
24
|
-
export function formatTime(unixS: number): string {
|
|
25
|
-
try {
|
|
26
|
-
return new Intl.DateTimeFormat(undefined, {
|
|
27
|
-
month: "short",
|
|
28
|
-
day: "2-digit",
|
|
29
|
-
hour: "numeric",
|
|
30
|
-
minute: "2-digit",
|
|
31
|
-
}).format(new Date(unixS * 1000));
|
|
32
|
-
} catch {
|
|
33
|
-
return "";
|
|
34
|
-
}
|
|
35
|
-
}
|
package/src/index.ts
DELETED
package/src/primitiveTypes.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { getAddress, Hex } from "viem";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
export const zBigIntStr = z
|
|
5
|
-
.string()
|
|
6
|
-
.regex(/^[0-9]+$/i)
|
|
7
|
-
.refine((s): s is BigIntStr => true);
|
|
8
|
-
|
|
9
|
-
export type BigIntStr = `${bigint}`;
|
|
10
|
-
|
|
11
|
-
export const zUUID = z.string().uuid();
|
|
12
|
-
|
|
13
|
-
export type UUID = z.infer<typeof zUUID>;
|
|
14
|
-
|
|
15
|
-
export const zAddress = z.string().transform((val) => getAddress(val));
|
|
16
|
-
|
|
17
|
-
export const zHex = z
|
|
18
|
-
.string()
|
|
19
|
-
.regex(/^0x[0-9a-f]*$/i)
|
|
20
|
-
.refine((s): s is Hex => true);
|
|
21
|
-
|
|
22
|
-
export const zSolanaPublicKey = z.string().regex(/^[1-9A-HJ-NP-Za-km-z]+$/);
|
|
23
|
-
|
|
24
|
-
export type SolanaPublicKey = z.infer<typeof zSolanaPublicKey>;
|
|
25
|
-
|
|
26
|
-
export type PlatformType = "ios" | "android" | "other";
|