@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
package/lib/cli/registry.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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 };
|
package/lib/cli/registry.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
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 };
|
package/lib/deployContract.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Account, Address } from "viem";
|
|
2
|
-
|
|
3
|
-
//#region src/deployContract.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Deploys any contract by name from the local contracts directory.
|
|
7
|
-
*/
|
|
8
|
-
declare function deployContract({
|
|
9
|
-
account,
|
|
10
|
-
contractName,
|
|
11
|
-
constructorArgs,
|
|
12
|
-
chain
|
|
13
|
-
}: {
|
|
14
|
-
account: Account;
|
|
15
|
-
contractName: string;
|
|
16
|
-
constructorArgs?: any[];
|
|
17
|
-
chain: any;
|
|
18
|
-
}): Promise<{
|
|
19
|
-
address: Address;
|
|
20
|
-
abi: any;
|
|
21
|
-
}>;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { deployContract };
|
package/lib/deployContract.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "fs";
|
|
2
|
-
import { fileURLToPath } from "url";
|
|
3
|
-
import { dirname, join } from "path";
|
|
4
|
-
import { createPublicClient, createWalletClient, encodeDeployData, http } from "viem";
|
|
5
|
-
import solc from "solc";
|
|
6
|
-
|
|
7
|
-
//#region src/deployContract.ts
|
|
8
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
function compileContract(contractName) {
|
|
10
|
-
const fileName = `${contractName}.sol`;
|
|
11
|
-
const source = readFileSync(join(__dirname, "..", "contracts", "src", fileName), "utf-8");
|
|
12
|
-
const input = {
|
|
13
|
-
language: "Solidity",
|
|
14
|
-
sources: { [fileName]: { content: source } },
|
|
15
|
-
settings: {
|
|
16
|
-
metadata: {
|
|
17
|
-
appendCBOR: false,
|
|
18
|
-
useLiteralContent: false
|
|
19
|
-
},
|
|
20
|
-
optimizer: {
|
|
21
|
-
enabled: true,
|
|
22
|
-
runs: 200
|
|
23
|
-
},
|
|
24
|
-
outputSelection: { "*": { "*": ["abi", "evm.bytecode"] } }
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const output = JSON.parse(solc.compile(JSON.stringify(input)));
|
|
28
|
-
const errors = output.errors?.filter((e) => e.severity === "error");
|
|
29
|
-
if (errors && errors.length > 0) {
|
|
30
|
-
console.error(`Compilation errors in ${fileName}:`, errors);
|
|
31
|
-
throw new Error(`${contractName} compilation failed`);
|
|
32
|
-
}
|
|
33
|
-
const contractData = output.contracts[fileName][contractName];
|
|
34
|
-
return {
|
|
35
|
-
abi: contractData.abi,
|
|
36
|
-
bytecode: contractData.evm.bytecode.object
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Deploys any contract by name from the local contracts directory.
|
|
41
|
-
*/
|
|
42
|
-
async function deployContract({ account, contractName, constructorArgs = [], chain }) {
|
|
43
|
-
console.log(`Compiling ${contractName}...`);
|
|
44
|
-
const compiled = compileContract(contractName);
|
|
45
|
-
const rpcUrl = process.env.CHAIN_RPC_URL;
|
|
46
|
-
if (!rpcUrl) throw new Error("CHAIN_RPC_URL environment variable required");
|
|
47
|
-
const publicClient = createPublicClient({ transport: http(rpcUrl) });
|
|
48
|
-
const walletClient = createWalletClient({
|
|
49
|
-
account,
|
|
50
|
-
transport: http(rpcUrl)
|
|
51
|
-
});
|
|
52
|
-
console.log(`Deploying ${contractName}...`);
|
|
53
|
-
const deployData = encodeDeployData({
|
|
54
|
-
abi: compiled.abi,
|
|
55
|
-
bytecode: `0x${compiled.bytecode}`,
|
|
56
|
-
args: constructorArgs
|
|
57
|
-
});
|
|
58
|
-
const gasPrice = await publicClient.getGasPrice();
|
|
59
|
-
console.log("the gas price is " + gasPrice);
|
|
60
|
-
const gasEstimate = await publicClient.estimateGas({
|
|
61
|
-
data: deployData,
|
|
62
|
-
account: walletClient.account.address
|
|
63
|
-
});
|
|
64
|
-
const txHash = await walletClient.sendTransaction({
|
|
65
|
-
data: deployData,
|
|
66
|
-
gas: gasEstimate + gasEstimate / 10n,
|
|
67
|
-
chain
|
|
68
|
-
});
|
|
69
|
-
const address = (await publicClient.waitForTransactionReceipt({ hash: txHash })).contractAddress;
|
|
70
|
-
console.log(`${contractName} deployed at: ${address}`);
|
|
71
|
-
return {
|
|
72
|
-
address,
|
|
73
|
-
abi: compiled.abi
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
//#endregion
|
|
78
|
-
export { deployContract };
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
//#region src/interface/datasource-registry/abi.ts
|
|
2
|
-
const DS_REGISTRY_ABI = [
|
|
3
|
-
{
|
|
4
|
-
name: "registerDataSource",
|
|
5
|
-
type: "function",
|
|
6
|
-
stateMutability: "nonpayable",
|
|
7
|
-
inputs: [{
|
|
8
|
-
name: "name",
|
|
9
|
-
type: "string"
|
|
10
|
-
}, {
|
|
11
|
-
name: "agentId",
|
|
12
|
-
type: "string"
|
|
13
|
-
}],
|
|
14
|
-
outputs: [{
|
|
15
|
-
name: "id",
|
|
16
|
-
type: "bytes32"
|
|
17
|
-
}]
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
name: "updateDataSource",
|
|
21
|
-
type: "function",
|
|
22
|
-
stateMutability: "nonpayable",
|
|
23
|
-
inputs: [{
|
|
24
|
-
name: "name",
|
|
25
|
-
type: "string"
|
|
26
|
-
}, {
|
|
27
|
-
name: "newManifestCid",
|
|
28
|
-
type: "string"
|
|
29
|
-
}],
|
|
30
|
-
outputs: []
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: "getDataSource",
|
|
34
|
-
type: "function",
|
|
35
|
-
stateMutability: "view",
|
|
36
|
-
inputs: [{
|
|
37
|
-
name: "owner",
|
|
38
|
-
type: "address"
|
|
39
|
-
}, {
|
|
40
|
-
name: "name",
|
|
41
|
-
type: "string"
|
|
42
|
-
}],
|
|
43
|
-
outputs: [{
|
|
44
|
-
name: "manifestCid",
|
|
45
|
-
type: "string"
|
|
46
|
-
}]
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: "getOwnedDataSources",
|
|
50
|
-
type: "function",
|
|
51
|
-
stateMutability: "view",
|
|
52
|
-
inputs: [{
|
|
53
|
-
name: "owner",
|
|
54
|
-
type: "address"
|
|
55
|
-
}],
|
|
56
|
-
outputs: [{ type: "bytes32[]" }]
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: "DataSourceCreated",
|
|
60
|
-
type: "event",
|
|
61
|
-
inputs: [
|
|
62
|
-
{
|
|
63
|
-
name: "id",
|
|
64
|
-
type: "bytes32",
|
|
65
|
-
indexed: true
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: "owner",
|
|
69
|
-
type: "address",
|
|
70
|
-
indexed: true
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: "name",
|
|
74
|
-
type: "string",
|
|
75
|
-
indexed: false
|
|
76
|
-
}
|
|
77
|
-
]
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
name: "DataSourceUpdated",
|
|
81
|
-
type: "event",
|
|
82
|
-
inputs: [{
|
|
83
|
-
name: "id",
|
|
84
|
-
type: "bytes32",
|
|
85
|
-
indexed: true
|
|
86
|
-
}, {
|
|
87
|
-
name: "newManifestCid",
|
|
88
|
-
type: "string",
|
|
89
|
-
indexed: false
|
|
90
|
-
}]
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: "NotOwner",
|
|
94
|
-
type: "error",
|
|
95
|
-
inputs: []
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
name: "DataSourceNotFound",
|
|
99
|
-
type: "error",
|
|
100
|
-
inputs: []
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
name: "DataSourceAlreadyExists",
|
|
104
|
-
type: "error",
|
|
105
|
-
inputs: []
|
|
106
|
-
}
|
|
107
|
-
];
|
|
108
|
-
|
|
109
|
-
//#endregion
|
|
110
|
-
export { DS_REGISTRY_ABI };
|
package/lib/interface/index.d.ts
DELETED
package/lib/interface/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { VaultEntry, VaultManifest } from "../types/index.js";
|
|
2
|
-
|
|
3
|
-
//#region src/interface/manifest.d.ts
|
|
4
|
-
declare function findEntry(manifest: VaultManifest, tag: string): VaultEntry | undefined;
|
|
5
|
-
declare function findEntryByCid(manifest: VaultManifest, cid: string): VaultEntry | undefined;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { findEntry, findEntryByCid };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
//#region src/interface/manifest.ts
|
|
2
|
-
function findEntry(manifest, tag) {
|
|
3
|
-
return manifest.entries.find((e) => e.tag === tag);
|
|
4
|
-
}
|
|
5
|
-
function findEntryByCid(manifest, cid) {
|
|
6
|
-
return manifest.entries.find((e) => e.cid === cid);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
10
|
-
export { findEntry, findEntryByCid };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
//#region src/interface/settlement-tracker/abi.d.ts
|
|
2
|
-
declare const SETTLEMENT_TRACKER_ABI: ({
|
|
3
|
-
name: string;
|
|
4
|
-
type: string;
|
|
5
|
-
stateMutability: string;
|
|
6
|
-
inputs: {
|
|
7
|
-
name: string;
|
|
8
|
-
type: string;
|
|
9
|
-
}[];
|
|
10
|
-
outputs: {
|
|
11
|
-
name: string;
|
|
12
|
-
type: string;
|
|
13
|
-
}[];
|
|
14
|
-
} | {
|
|
15
|
-
name: string;
|
|
16
|
-
type: string;
|
|
17
|
-
inputs: {
|
|
18
|
-
name: string;
|
|
19
|
-
type: string;
|
|
20
|
-
indexed: boolean;
|
|
21
|
-
}[];
|
|
22
|
-
stateMutability?: undefined;
|
|
23
|
-
outputs?: undefined;
|
|
24
|
-
})[];
|
|
25
|
-
//#endregion
|
|
26
|
-
export { SETTLEMENT_TRACKER_ABI };
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
//#region src/interface/settlement-tracker/abi.ts
|
|
2
|
-
const SETTLEMENT_TRACKER_ABI = [
|
|
3
|
-
{
|
|
4
|
-
name: "pay",
|
|
5
|
-
type: "function",
|
|
6
|
-
stateMutability: "payable",
|
|
7
|
-
inputs: [
|
|
8
|
-
{
|
|
9
|
-
name: "commitment",
|
|
10
|
-
type: "bytes32"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
name: "from",
|
|
14
|
-
type: "address"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
name: "to",
|
|
18
|
-
type: "address"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
name: "value",
|
|
22
|
-
type: "uint256"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: "validAfter",
|
|
26
|
-
type: "uint256"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: "validBefore",
|
|
30
|
-
type: "uint256"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: "nonce",
|
|
34
|
-
type: "bytes32"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: "v",
|
|
38
|
-
type: "uint8"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: "r",
|
|
42
|
-
type: "bytes32"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: "s",
|
|
46
|
-
type: "bytes32"
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
outputs: []
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: "checkSettlement",
|
|
53
|
-
type: "function",
|
|
54
|
-
stateMutability: "view",
|
|
55
|
-
inputs: [{
|
|
56
|
-
name: "commitment",
|
|
57
|
-
type: "bytes32"
|
|
58
|
-
}, {
|
|
59
|
-
name: "user",
|
|
60
|
-
type: "address"
|
|
61
|
-
}],
|
|
62
|
-
outputs: [{
|
|
63
|
-
name: "amount",
|
|
64
|
-
type: "uint256"
|
|
65
|
-
}]
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: "SettlementRecordedd",
|
|
69
|
-
type: "event",
|
|
70
|
-
inputs: [{
|
|
71
|
-
name: "hash",
|
|
72
|
-
type: "bytes32",
|
|
73
|
-
indexed: true
|
|
74
|
-
}, {
|
|
75
|
-
name: "amount",
|
|
76
|
-
type: "uint256",
|
|
77
|
-
indexed: false
|
|
78
|
-
}]
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
name: "TransferFailed",
|
|
82
|
-
type: "error",
|
|
83
|
-
inputs: []
|
|
84
|
-
}
|
|
85
|
-
];
|
|
86
|
-
|
|
87
|
-
//#endregion
|
|
88
|
-
export { SETTLEMENT_TRACKER_ABI };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import * as viem0 from "viem";
|
|
2
|
-
import { Address, Hash, Hex, PublicClient, WalletClient } from "viem";
|
|
3
|
-
|
|
4
|
-
//#region src/interface/settlement-tracker/settlementTracker.d.ts
|
|
5
|
-
declare class SettlementTracker {
|
|
6
|
-
private publicClient;
|
|
7
|
-
private walletClient;
|
|
8
|
-
private contractAddress;
|
|
9
|
-
constructor(contractAddress: Address, publicClient: PublicClient, walletClient: WalletClient);
|
|
10
|
-
private getWriteConfig;
|
|
11
|
-
getContractAddress(): `0x${string}`;
|
|
12
|
-
checkSettlement(commitment: Hex, user: Address): Promise<boolean>;
|
|
13
|
-
/**
|
|
14
|
-
* Settles the payment on-chain using the EIP-3009 authorization
|
|
15
|
-
* This is usually called by the Facilitator.
|
|
16
|
-
*/
|
|
17
|
-
pay(args: {
|
|
18
|
-
commitment: Hex;
|
|
19
|
-
from: Address;
|
|
20
|
-
to: Address;
|
|
21
|
-
value: bigint;
|
|
22
|
-
validAfter: bigint;
|
|
23
|
-
validBefore: bigint;
|
|
24
|
-
nonce: Hex;
|
|
25
|
-
v: number;
|
|
26
|
-
r: Hex;
|
|
27
|
-
s: Hex;
|
|
28
|
-
}): Promise<Hash>;
|
|
29
|
-
waitForTransaction(hash: Hash): Promise<viem0.TransactionReceipt>;
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
export { SettlementTracker };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { SETTLEMENT_TRACKER_ABI } from "./abi.js";
|
|
2
|
-
|
|
3
|
-
//#region src/interface/settlement-tracker/settlementTracker.ts
|
|
4
|
-
var SettlementTracker = class {
|
|
5
|
-
publicClient;
|
|
6
|
-
walletClient;
|
|
7
|
-
contractAddress;
|
|
8
|
-
constructor(contractAddress, publicClient, walletClient) {
|
|
9
|
-
this.publicClient = publicClient;
|
|
10
|
-
this.contractAddress = contractAddress;
|
|
11
|
-
this.walletClient = walletClient;
|
|
12
|
-
}
|
|
13
|
-
getWriteConfig() {
|
|
14
|
-
if (!this.walletClient.chain) throw new Error("Chain required");
|
|
15
|
-
if (!this.walletClient.account) throw new Error("Account required");
|
|
16
|
-
return {
|
|
17
|
-
chain: this.walletClient.chain,
|
|
18
|
-
account: this.walletClient.account
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
getContractAddress() {
|
|
22
|
-
return this.contractAddress;
|
|
23
|
-
}
|
|
24
|
-
async checkSettlement(commitment, user) {
|
|
25
|
-
return await this.publicClient.readContract({
|
|
26
|
-
address: this.contractAddress,
|
|
27
|
-
abi: SETTLEMENT_TRACKER_ABI,
|
|
28
|
-
functionName: "checkSettlement",
|
|
29
|
-
args: [commitment, user]
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Settles the payment on-chain using the EIP-3009 authorization
|
|
34
|
-
* This is usually called by the Facilitator.
|
|
35
|
-
*/
|
|
36
|
-
async pay(args) {
|
|
37
|
-
const { chain, account } = this.getWriteConfig();
|
|
38
|
-
return this.walletClient.writeContract({
|
|
39
|
-
address: this.contractAddress,
|
|
40
|
-
abi: SETTLEMENT_TRACKER_ABI,
|
|
41
|
-
functionName: "pay",
|
|
42
|
-
args: [
|
|
43
|
-
args.commitment,
|
|
44
|
-
args.from,
|
|
45
|
-
args.to,
|
|
46
|
-
args.value,
|
|
47
|
-
args.validAfter,
|
|
48
|
-
args.validBefore,
|
|
49
|
-
args.nonce,
|
|
50
|
-
args.v,
|
|
51
|
-
args.r,
|
|
52
|
-
args.s
|
|
53
|
-
],
|
|
54
|
-
chain,
|
|
55
|
-
account
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
async waitForTransaction(hash) {
|
|
59
|
-
return this.publicClient.waitForTransactionReceipt({ hash });
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
//#endregion
|
|
64
|
-
export { SettlementTracker };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AccGadget } from "../acc.js";
|
|
2
|
-
import { createAccBuilder } from "@lit-protocol/access-control-conditions";
|
|
3
|
-
|
|
4
|
-
//#region src/modules/gadgets/acc/gadgets.ts
|
|
5
|
-
function identity(chain, who) {
|
|
6
|
-
return new AccGadget(createAccBuilder().requireWalletOwnership(who).on(chain).build(), "Caller must match the specified wallet.");
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
10
|
-
export { identity };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Gadget, GadgetDescriptor } from "./types.js";
|
|
2
|
-
import { AccessControlConditions } from "@lit-protocol/access-control-conditions";
|
|
3
|
-
|
|
4
|
-
//#region src/modules/gadgets/acc.d.ts
|
|
5
|
-
declare class AccGadget implements Gadget {
|
|
6
|
-
private acc;
|
|
7
|
-
private description?;
|
|
8
|
-
readonly type = "acc";
|
|
9
|
-
constructor(acc: AccessControlConditions, description?: string);
|
|
10
|
-
toLitAction(): string;
|
|
11
|
-
toAccessCondition(): Promise<AccessControlConditions>;
|
|
12
|
-
toDescriptor(): GadgetDescriptor;
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
export { AccGadget };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//#region src/modules/gadgets/acc.ts
|
|
2
|
-
var AccGadget = class {
|
|
3
|
-
type = "acc";
|
|
4
|
-
constructor(acc, description) {
|
|
5
|
-
this.acc = acc;
|
|
6
|
-
this.description = description;
|
|
7
|
-
}
|
|
8
|
-
toLitAction() {
|
|
9
|
-
return ``;
|
|
10
|
-
}
|
|
11
|
-
async toAccessCondition() {
|
|
12
|
-
return this.acc;
|
|
13
|
-
}
|
|
14
|
-
toDescriptor() {
|
|
15
|
-
return {
|
|
16
|
-
type: this.type,
|
|
17
|
-
description: this.description,
|
|
18
|
-
acc: this.acc
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
export { AccGadget };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Gadget, GadgetDescriptor } from "./types.js";
|
|
2
|
-
import { Address, Hex } from "viem";
|
|
3
|
-
|
|
4
|
-
//#region src/modules/gadgets/payment.d.ts
|
|
5
|
-
interface PaymentGadgetParams {
|
|
6
|
-
usdcPrice: string;
|
|
7
|
-
commitment: Hex;
|
|
8
|
-
chainName: string;
|
|
9
|
-
settlementTrackerContractAddress: Address;
|
|
10
|
-
pinataJwt: String;
|
|
11
|
-
}
|
|
12
|
-
declare class PaymentGadget implements Gadget {
|
|
13
|
-
private params;
|
|
14
|
-
readonly type = "payment";
|
|
15
|
-
private litActionCid;
|
|
16
|
-
constructor(params: PaymentGadgetParams);
|
|
17
|
-
toLitAction(): string;
|
|
18
|
-
toAccessCondition(): Promise<any>;
|
|
19
|
-
toDescriptor(): GadgetDescriptor;
|
|
20
|
-
private toLitActionIpfsHash;
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
export { PaymentGadget, PaymentGadgetParams };
|