@fangorn-network/sdk 2026.3.11
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/LICENSE.md +20 -0
- package/README.md +276 -0
- package/lib/builders/a2aCardBuilder.d.ts +28 -0
- package/lib/builders/a2aCardBuilder.js +104 -0
- package/lib/cli/cli.d.ts +2 -0
- package/lib/cli/cli.js +500 -0
- package/lib/cli/index.d.ts +738 -0
- package/lib/cli/index.js +36 -0
- package/lib/cli/registry.d.ts +29 -0
- package/lib/cli/registry.js +53 -0
- package/lib/config.d.ts +761 -0
- package/lib/config.js +46 -0
- package/lib/deployContract.d.ts +23 -0
- package/lib/deployContract.js +78 -0
- package/lib/fangorn.d.ts +59 -0
- package/lib/fangorn.js +145 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +11 -0
- package/lib/interface/datasource-registry/abi.d.ts +97 -0
- package/lib/interface/datasource-registry/abi.js +110 -0
- package/lib/interface/datasource-registry/dataSourceRegistry.d.ts +24 -0
- package/lib/interface/datasource-registry/dataSourceRegistry.js +81 -0
- package/lib/interface/index.d.ts +3 -0
- package/lib/interface/index.js +4 -0
- package/lib/interface/manifest.d.ts +7 -0
- package/lib/interface/manifest.js +10 -0
- package/lib/interface/settlement-tracker/abi.d.ts +26 -0
- package/lib/interface/settlement-tracker/abi.js +88 -0
- package/lib/interface/settlement-tracker/settlementTracker.d.ts +32 -0
- package/lib/interface/settlement-tracker/settlementTracker.js +64 -0
- package/lib/modules/encryption/actions.d.ts +4 -0
- package/lib/modules/encryption/actions.js +18 -0
- package/lib/modules/encryption/aes.d.ts +10 -0
- package/lib/modules/encryption/aes.js +51 -0
- package/lib/modules/encryption/index.d.ts +27 -0
- package/lib/modules/encryption/index.js +3 -0
- package/lib/modules/encryption/lit.d.ts +36 -0
- package/lib/modules/encryption/lit.js +156 -0
- package/lib/modules/encryption/rand.d.ts +5 -0
- package/lib/modules/encryption/rand.js +16 -0
- package/lib/modules/encryption/types.d.ts +55 -0
- package/lib/modules/encryption/types.js +1 -0
- package/lib/modules/gadgets/acc/gadgets.d.ts +7 -0
- package/lib/modules/gadgets/acc/gadgets.js +10 -0
- package/lib/modules/gadgets/acc.d.ts +15 -0
- package/lib/modules/gadgets/acc.js +24 -0
- package/lib/modules/gadgets/builder.d.ts +1 -0
- package/lib/modules/gadgets/builder.js +1 -0
- package/lib/modules/gadgets/index.d.ts +2 -0
- package/lib/modules/gadgets/index.js +1 -0
- package/lib/modules/gadgets/payment.d.ts +23 -0
- package/lib/modules/gadgets/payment.js +88 -0
- package/lib/modules/gadgets/types.d.ts +15 -0
- package/lib/modules/gadgets/types.js +1 -0
- package/lib/providers/storage/index.d.ts +10 -0
- package/lib/providers/storage/index.js +3 -0
- package/lib/providers/storage/pinata/index.d.ts +12 -0
- package/lib/providers/storage/pinata/index.js +26 -0
- package/lib/providers/storage/s3/index.d.ts +1 -0
- package/lib/providers/storage/s3/index.js +1 -0
- package/lib/test/index.d.ts +7 -0
- package/lib/test/index.js +25 -0
- package/lib/test/test-gadget.d.ts +7 -0
- package/lib/test/test-gadget.js +10 -0
- package/lib/test/testbed.d.ts +43 -0
- package/lib/test/testbed.js +174 -0
- package/lib/types/index.d.ts +43 -0
- package/lib/types/index.js +12 -0
- package/lib/utils/index.d.ts +12 -0
- package/lib/utils/index.js +43 -0
- package/package.json +83 -0
package/lib/cli/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import getNetwork from "../config.js";
|
|
2
|
+
import "./cli.js";
|
|
3
|
+
import { isCancel, select } from "@clack/prompts";
|
|
4
|
+
|
|
5
|
+
//#region src/cli/index.ts
|
|
6
|
+
const getChain = (chainStr) => {
|
|
7
|
+
return getNetwork(chainStr);
|
|
8
|
+
};
|
|
9
|
+
const handleCancel = (value) => {
|
|
10
|
+
if (isCancel(value)) process.exit(0);
|
|
11
|
+
};
|
|
12
|
+
const selectChain = async () => {
|
|
13
|
+
const chainChoice = await select({
|
|
14
|
+
message: "Pick your chain.",
|
|
15
|
+
options: [{
|
|
16
|
+
value: "arbitrumSepolia",
|
|
17
|
+
label: "Arbitrum Sepolia"
|
|
18
|
+
}, {
|
|
19
|
+
value: "baseSepolia",
|
|
20
|
+
label: "Base Sepolia"
|
|
21
|
+
}]
|
|
22
|
+
});
|
|
23
|
+
handleCancel(chainChoice);
|
|
24
|
+
return getNetwork(chainChoice.toString());
|
|
25
|
+
};
|
|
26
|
+
function parseGadgetArg(raw) {
|
|
27
|
+
const match = raw.match(/^(\w+)\(([^)]*)\)$/);
|
|
28
|
+
if (!match) throw new Error(`Invalid gadget format: "${raw}". Expected e.g. Payment(0.00001)`);
|
|
29
|
+
return {
|
|
30
|
+
type: match[1].toLowerCase(),
|
|
31
|
+
args: match[2].split(",").map((s) => s.trim()).filter(Boolean)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { getChain, handleCancel, parseGadgetArg, selectChain };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Gadget } from "../modules/gadgets/types.js";
|
|
2
|
+
import { PaymentGadget } from "../modules/gadgets/payment.js";
|
|
3
|
+
import { Address } from "viem";
|
|
4
|
+
|
|
5
|
+
//#region src/cli/registry.d.ts
|
|
6
|
+
declare const GADGET_REGISTRY: {
|
|
7
|
+
readonly payment: {
|
|
8
|
+
readonly label: "Payment (x402)";
|
|
9
|
+
readonly argSchema: readonly ["usdcPrice"];
|
|
10
|
+
readonly build: (namedParams: Record<string, unknown>) => PaymentGadget;
|
|
11
|
+
readonly prompts: readonly [{
|
|
12
|
+
readonly key: "usdcPrice";
|
|
13
|
+
readonly message: "USDC price:";
|
|
14
|
+
readonly placeholder: "1.00";
|
|
15
|
+
}, {
|
|
16
|
+
readonly key: "chainName";
|
|
17
|
+
readonly message: "Chain name:";
|
|
18
|
+
readonly placeholder: "arbitrumSepolia";
|
|
19
|
+
}, {
|
|
20
|
+
readonly key: "settlementTrackerContractAddress";
|
|
21
|
+
readonly message: "Settlement tracker contract address:";
|
|
22
|
+
readonly placeholder: "0x...";
|
|
23
|
+
}];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
declare function selectGadget(owner: Address, name: string, tag: string, price: string): Promise<Gadget>;
|
|
27
|
+
type GadgetType = keyof typeof GADGET_REGISTRY;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { GADGET_REGISTRY, GadgetType, selectGadget };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { computeTagCommitment, fieldToHex } from "../utils/index.js";
|
|
2
|
+
import { handleCancel } from "./index.js";
|
|
3
|
+
import { PaymentGadget } from "../modules/gadgets/payment.js";
|
|
4
|
+
import { select, text } from "@clack/prompts";
|
|
5
|
+
|
|
6
|
+
//#region src/cli/registry.ts
|
|
7
|
+
const GADGET_REGISTRY = { payment: {
|
|
8
|
+
label: "Payment (x402)",
|
|
9
|
+
argSchema: ["usdcPrice"],
|
|
10
|
+
build: (namedParams) => new PaymentGadget(namedParams),
|
|
11
|
+
prompts: [
|
|
12
|
+
{
|
|
13
|
+
key: "usdcPrice",
|
|
14
|
+
message: "USDC price:",
|
|
15
|
+
placeholder: "1.00"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
key: "chainName",
|
|
19
|
+
message: "Chain name:",
|
|
20
|
+
placeholder: "arbitrumSepolia"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
key: "settlementTrackerContractAddress",
|
|
24
|
+
message: "Settlement tracker contract address:",
|
|
25
|
+
placeholder: "0x..."
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
} };
|
|
29
|
+
async function selectGadget(owner, name, tag, price) {
|
|
30
|
+
const gadgetType = await select({
|
|
31
|
+
message: "Select access control gadget:",
|
|
32
|
+
options: Object.entries(GADGET_REGISTRY).map(([value, { label }]) => ({
|
|
33
|
+
value,
|
|
34
|
+
label
|
|
35
|
+
}))
|
|
36
|
+
});
|
|
37
|
+
handleCancel(gadgetType);
|
|
38
|
+
const def = GADGET_REGISTRY[gadgetType];
|
|
39
|
+
const params = {};
|
|
40
|
+
for (const { key, message, placeholder } of def.prompts) {
|
|
41
|
+
const val = await text({
|
|
42
|
+
message,
|
|
43
|
+
placeholder
|
|
44
|
+
});
|
|
45
|
+
handleCancel(val);
|
|
46
|
+
params[key] = val;
|
|
47
|
+
}
|
|
48
|
+
params.commitment = fieldToHex(await computeTagCommitment(owner, name, tag, price));
|
|
49
|
+
return def.build(params);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { GADGET_REGISTRY, selectGadget };
|