@pay-skill/sdk 0.1.1 → 0.1.3

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,66 +1,66 @@
1
- import { describe, it } from "node:test";
2
- import assert from "node:assert/strict";
3
- import { PayClient } from "../src/client.js";
4
- import { PayValidationError } from "../src/errors.js";
5
- import { CallbackSigner } from "../src/signer.js";
6
-
7
- const VALID_ADDR = "0x" + "a1".repeat(20);
8
- const dummySigner = new CallbackSigner(() => new Uint8Array(65));
9
-
10
- const client = new PayClient({
11
- apiUrl: "http://localhost:9999",
12
- signer: dummySigner,
13
- });
14
-
15
- describe("payDirect validation", () => {
16
- it("rejects invalid address", async () => {
17
- await assert.rejects(
18
- () => client.payDirect("not-an-address", 1_000_000),
19
- PayValidationError
20
- );
21
- });
22
-
23
- it("rejects amount below minimum", async () => {
24
- await assert.rejects(
25
- () => client.payDirect(VALID_ADDR, 500_000),
26
- PayValidationError
27
- );
28
- });
29
-
30
- it("accepts valid inputs (fails on network, not validation)", async () => {
31
- // This should fail with a network error, not validation
32
- await assert.rejects(
33
- () => client.payDirect(VALID_ADDR, 1_000_000),
34
- (err: Error) => {
35
- assert.ok(!(err instanceof PayValidationError));
36
- return true;
37
- }
38
- );
39
- });
40
- });
41
-
42
-
43
- describe("openTab validation", () => {
44
- it("rejects amount below $5 minimum", async () => {
45
- await assert.rejects(
46
- () =>
47
- client.openTab(VALID_ADDR, 1_000_000, { maxChargePerCall: 100_000 }),
48
- PayValidationError
49
- );
50
- });
51
-
52
- it("rejects zero maxChargePerCall", async () => {
53
- await assert.rejects(
54
- () => client.openTab(VALID_ADDR, 10_000_000, { maxChargePerCall: 0 }),
55
- PayValidationError
56
- );
57
- });
58
-
59
- it("rejects invalid provider address", async () => {
60
- await assert.rejects(
61
- () =>
62
- client.openTab("bad-addr", 10_000_000, { maxChargePerCall: 500_000 }),
63
- PayValidationError
64
- );
65
- });
66
- });
1
+ import { describe, it } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { PayClient } from "../src/client.js";
4
+ import { PayValidationError } from "../src/errors.js";
5
+ import { CallbackSigner } from "../src/signer.js";
6
+
7
+ const VALID_ADDR = "0x" + "a1".repeat(20);
8
+ const dummySigner = new CallbackSigner(() => new Uint8Array(65));
9
+
10
+ const client = new PayClient({
11
+ apiUrl: "http://localhost:9999",
12
+ signer: dummySigner,
13
+ });
14
+
15
+ describe("payDirect validation", () => {
16
+ it("rejects invalid address", async () => {
17
+ await assert.rejects(
18
+ () => client.payDirect("not-an-address", 1_000_000),
19
+ PayValidationError
20
+ );
21
+ });
22
+
23
+ it("rejects amount below minimum", async () => {
24
+ await assert.rejects(
25
+ () => client.payDirect(VALID_ADDR, 500_000),
26
+ PayValidationError
27
+ );
28
+ });
29
+
30
+ it("accepts valid inputs (fails on network, not validation)", async () => {
31
+ // This should fail with a network error, not validation
32
+ await assert.rejects(
33
+ () => client.payDirect(VALID_ADDR, 1_000_000),
34
+ (err: Error) => {
35
+ assert.ok(!(err instanceof PayValidationError));
36
+ return true;
37
+ }
38
+ );
39
+ });
40
+ });
41
+
42
+
43
+ describe("openTab validation", () => {
44
+ it("rejects amount below $5 minimum", async () => {
45
+ await assert.rejects(
46
+ () =>
47
+ client.openTab(VALID_ADDR, 1_000_000, { maxChargePerCall: 100_000 }),
48
+ PayValidationError
49
+ );
50
+ });
51
+
52
+ it("rejects zero maxChargePerCall", async () => {
53
+ await assert.rejects(
54
+ () => client.openTab(VALID_ADDR, 10_000_000, { maxChargePerCall: 0 }),
55
+ PayValidationError
56
+ );
57
+ });
58
+
59
+ it("rejects invalid provider address", async () => {
60
+ await assert.rejects(
61
+ () =>
62
+ client.openTab("bad-addr", 10_000_000, { maxChargePerCall: 500_000 }),
63
+ PayValidationError
64
+ );
65
+ });
66
+ });