@fangorn-network/sdk 2026.3.11 → 2026.3.27
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 +311 -198
- package/lib/builders/a2aCardBuilder.js +1 -0
- package/lib/cli/cli.js +406 -379
- package/lib/cli/index.d.ts +170 -170
- package/lib/cli/index.js +1 -4
- package/lib/config.d.ts +543 -163
- package/lib/config.js +11 -8
- package/lib/fangorn.d.ts +28 -45
- package/lib/fangorn.js +98 -119
- package/lib/index.d.ts +8 -5
- package/lib/index.js +8 -7
- package/lib/modules/encryption/index.d.ts +4 -3
- package/lib/modules/encryption/lit.d.ts +3 -18
- package/lib/modules/encryption/lit.js +20 -49
- package/lib/modules/encryption/rand.js +2 -2
- package/lib/modules/encryption/types.d.ts +23 -8
- package/lib/modules/gadgets/settledGadget.d.ts +26 -0
- package/lib/modules/gadgets/settledGadget.js +63 -0
- package/lib/modules/gadgets/types.d.ts +16 -4
- package/lib/providers/storage/index.d.ts +15 -4
- package/lib/providers/storage/pinata/index.d.ts +5 -4
- package/lib/providers/storage/pinata/index.js +17 -2
- package/lib/providers/storage/storacha/index.d.ts +13 -0
- package/lib/providers/storage/storacha/index.js +49 -0
- package/lib/providers/storage/storacha/readOnly.d.ts +8 -0
- package/lib/providers/storage/storacha/readOnly.js +16 -0
- package/lib/{interface → registries}/datasource-registry/abi.d.ts +29 -43
- package/lib/registries/datasource-registry/abi.js +16 -0
- package/lib/{interface/datasource-registry/dataSourceRegistry.d.ts → registries/datasource-registry/index.d.ts} +9 -9
- package/lib/{interface/datasource-registry/dataSourceRegistry.js → registries/datasource-registry/index.js} +35 -34
- package/lib/registries/index.d.ts +3 -0
- package/lib/registries/index.js +4 -0
- package/lib/registries/schema-registry/abi.d.ts +127 -0
- package/lib/registries/schema-registry/abi.js +19 -0
- package/lib/registries/schema-registry/index.d.ts +29 -0
- package/lib/registries/schema-registry/index.js +114 -0
- package/lib/registries/settlement-registry/abi.d.ts +228 -0
- package/lib/registries/settlement-registry/abi.js +29 -0
- package/lib/registries/settlement-registry/index.d.ts +72 -0
- package/lib/registries/settlement-registry/index.js +316 -0
- package/lib/registries/settlement-registry/types.d.ts +51 -0
- package/lib/roles/consumer/index.d.ts +64 -0
- package/lib/roles/consumer/index.js +114 -0
- package/lib/roles/consumer/types.d.ts +66 -0
- package/lib/roles/index.js +1 -0
- package/lib/roles/publisher/index.d.ts +70 -0
- package/lib/roles/publisher/index.js +203 -0
- package/lib/roles/publisher/types.d.ts +93 -0
- package/lib/roles/publisher/types.js +1 -0
- package/lib/roles/schema/index.d.ts +44 -0
- package/lib/roles/schema/index.js +137 -0
- package/lib/roles/schema/types.d.ts +67 -0
- package/lib/roles/schema/types.js +1 -0
- package/lib/test/index.d.ts +5 -2
- package/lib/test/index.js +5 -3
- package/lib/test/testbed.d.ts +54 -32
- package/lib/test/testbed.js +149 -135
- package/lib/types/index.d.ts +65 -21
- package/lib/types/index.js +1 -12
- package/lib/utils/index.d.ts +2 -3
- package/lib/utils/index.js +4 -18
- package/package.json +9 -18
- package/lib/cli/registry.d.ts +0 -29
- package/lib/cli/registry.js +0 -53
- package/lib/deployContract.d.ts +0 -23
- package/lib/deployContract.js +0 -78
- package/lib/interface/datasource-registry/abi.js +0 -110
- package/lib/interface/index.d.ts +0 -3
- package/lib/interface/index.js +0 -4
- package/lib/interface/manifest.d.ts +0 -7
- package/lib/interface/manifest.js +0 -10
- package/lib/interface/settlement-tracker/abi.d.ts +0 -26
- package/lib/interface/settlement-tracker/abi.js +0 -88
- package/lib/interface/settlement-tracker/settlementTracker.d.ts +0 -32
- package/lib/interface/settlement-tracker/settlementTracker.js +0 -64
- package/lib/modules/gadgets/acc/gadgets.d.ts +0 -7
- package/lib/modules/gadgets/acc/gadgets.js +0 -10
- package/lib/modules/gadgets/acc.d.ts +0 -15
- package/lib/modules/gadgets/acc.js +0 -24
- package/lib/modules/gadgets/builder.d.ts +0 -1
- package/lib/modules/gadgets/payment.d.ts +0 -23
- package/lib/modules/gadgets/payment.js +0 -88
- package/lib/test/test-gadget.d.ts +0 -7
- package/lib/test/test-gadget.js +0 -10
- /package/lib/{modules/gadgets/builder.js → registries/settlement-registry/types.js} +0 -0
- /package/lib/{providers/storage/s3/index.js → roles/consumer/types.js} +0 -0
- /package/lib/{providers/storage/s3 → roles}/index.d.ts +0 -0
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { createAccBuilder } from "@lit-protocol/access-control-conditions";
|
|
2
|
-
|
|
3
|
-
//#region src/modules/gadgets/payment.ts
|
|
4
|
-
var PaymentGadget = class {
|
|
5
|
-
type = "payment";
|
|
6
|
-
litActionCid = null;
|
|
7
|
-
constructor(params) {
|
|
8
|
-
this.params = params;
|
|
9
|
-
}
|
|
10
|
-
toLitAction() {
|
|
11
|
-
return `
|
|
12
|
-
const arbitrumSepolia = "https://sepolia-rollup.arbitrum.io/rpc";
|
|
13
|
-
const baseSepolia = "https://sepolia.base.org";
|
|
14
|
-
|
|
15
|
-
const go = async (supportedNetwork, paywallAddress, commitment, price) => {
|
|
16
|
-
let rpcUrl = baseSepolia;
|
|
17
|
-
if (supportedNetwork == "arbitrumSepolia") rpcUrl = arbitrumSepolia;
|
|
18
|
-
else if (supportedNetwork == "baseSepolia") rpcUrl = baseSepolia;
|
|
19
|
-
else {
|
|
20
|
-
throw new Error(
|
|
21
|
-
'Unsupported network.Choose a supported network in the list ["arbitrumSepolia", "baseSepolia"].'
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const callerAddress = Lit.Auth.authSigAddress;
|
|
26
|
-
const provider = new ethers.providers.JsonRpcProvider(rpcUrl);
|
|
27
|
-
|
|
28
|
-
const paywallAbi = [
|
|
29
|
-
"function checkSettlement(bytes32 commitment, address user) external view returns (uint256)",
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
const paywall = new ethers.Contract(paywallAddress, paywallAbi, provider);
|
|
33
|
-
|
|
34
|
-
const paidAmount = await paywall.checkSettlement(commitment, callerAddress);
|
|
35
|
-
|
|
36
|
-
if (paidAmount < price) {
|
|
37
|
-
Lit.Actions.setResponse({ success: false, response: "goodbye" });
|
|
38
|
-
throw new Error("x402: Payment Required. " + paidAmount + " < " + price + " with commitment " + commitment );
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
Lit.Actions.setResponse({ response: true.toString() });
|
|
42
|
-
|
|
43
|
-
return true.toString()
|
|
44
|
-
};
|
|
45
|
-
`;
|
|
46
|
-
}
|
|
47
|
-
async toAccessCondition() {
|
|
48
|
-
return createAccBuilder().requireLitAction(await this.toLitActionIpfsHash(), "go", [
|
|
49
|
-
this.params.chainName,
|
|
50
|
-
this.params.settlementTrackerContractAddress,
|
|
51
|
-
this.params.commitment,
|
|
52
|
-
this.params.usdcPrice
|
|
53
|
-
], "true").build();
|
|
54
|
-
}
|
|
55
|
-
toDescriptor() {
|
|
56
|
-
return {
|
|
57
|
-
type: this.type,
|
|
58
|
-
description: "x402: Payment Required",
|
|
59
|
-
acc: this.toAccessCondition(),
|
|
60
|
-
params: {
|
|
61
|
-
price: this.params.usdcPrice,
|
|
62
|
-
token: "USDC"
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
async toLitActionIpfsHash() {
|
|
67
|
-
const content = this.toLitAction();
|
|
68
|
-
const name = "lit-action-payment-gadget-v1";
|
|
69
|
-
const form = new FormData();
|
|
70
|
-
form.append("file", new Blob([content], { type: "text/plain" }), name);
|
|
71
|
-
form.append("pinataOptions", JSON.stringify({ cidVersion: 0 }));
|
|
72
|
-
form.append("pinataMetadata", JSON.stringify({ name }));
|
|
73
|
-
const res = await fetch("https://api.pinata.cloud/pinning/pinFileToIPFS", {
|
|
74
|
-
method: "POST",
|
|
75
|
-
headers: { Authorization: `Bearer ${this.params.pinataJwt}` },
|
|
76
|
-
body: form
|
|
77
|
-
});
|
|
78
|
-
if (!res.ok) {
|
|
79
|
-
const text = await res.text();
|
|
80
|
-
throw new Error(`Pinata upload failed: ${res.status} - ${text}`);
|
|
81
|
-
}
|
|
82
|
-
this.litActionCid = (await res.json()).IpfsHash;
|
|
83
|
-
return this.litActionCid;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
//#endregion
|
|
88
|
-
export { PaymentGadget };
|
package/lib/test/test-gadget.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AccGadget } from "../modules/gadgets/acc.js";
|
|
2
|
-
import { createAccBuilder } from "@lit-protocol/access-control-conditions";
|
|
3
|
-
|
|
4
|
-
//#region src/test/test-gadget.ts
|
|
5
|
-
function emptyWallet(chain) {
|
|
6
|
-
return new AccGadget(createAccBuilder().requireEthBalance("0", "=").on(chain).build(), "Caller must have zero ETH balance");
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
10
|
-
export { emptyWallet };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|