@openfort/openfort-node 0.8.4 → 0.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfort/openfort-node",
3
- "version": "0.8.4",
3
+ "version": "0.9.0",
4
4
  "description": "Openfort Node SDK",
5
5
  "author": "Openfort",
6
6
  "repository": {
@@ -1,43 +0,0 @@
1
- // Usage: npx tsx fee-sponsorship/createPolicyRule.ts
2
-
3
- import Openfort from "@openfort/openfort-node";
4
- import "dotenv/config";
5
-
6
- const openfort = new Openfort(process.env.OPENFORT_API_KEY!, {
7
- basePath: process.env.OPENFORT_BASE_URL,
8
- });
9
-
10
- const chainId = Number(process.env.CHAIN_ID) || 80002;
11
-
12
- // Create a policy first
13
- const policy = await openfort.feeSponsorship.create({
14
- name: `PolicyWithRules-${Date.now()}`,
15
- chainId,
16
- strategy: {
17
- sponsorSchema: "pay_for_user",
18
- },
19
- });
20
- console.log("Created policy:", policy.id);
21
-
22
- // Create a contract to reference in the rule
23
- const contract = await openfort.contracts.create({
24
- name: "Test Contract",
25
- chainId,
26
- address: "0x38090d1636069c0ff1af6bc1737fb996b7f63ac0",
27
- });
28
- console.log("Created contract:", contract.id);
29
-
30
- // Create a policy rule for account functions
31
- const rule = await openfort.feeSponsorship.rules.create({
32
- type: "account_functions",
33
- policy: policy.id,
34
- functionName: "transfer",
35
- contract: contract.id,
36
- });
37
-
38
- console.log("\nCreated policy rule:");
39
- console.log(" ID:", rule.id);
40
- console.log(" Type:", rule.type);
41
- if ("functionName" in rule && rule.functionName) {
42
- console.log(" Function:", rule.functionName);
43
- }
@@ -1,37 +0,0 @@
1
- // Usage: npx tsx fee-sponsorship/listPolicyRules.ts
2
-
3
- import Openfort from "@openfort/openfort-node";
4
- import "dotenv/config";
5
-
6
- const openfort = new Openfort(process.env.OPENFORT_API_KEY!, {
7
- basePath: process.env.OPENFORT_BASE_URL,
8
- });
9
-
10
- const chainId = Number(process.env.CHAIN_ID) || 80002;
11
-
12
- // Create a policy with rules
13
- const policy = await openfort.feeSponsorship.create({
14
- name: `PolicyWithRules-${Date.now()}`,
15
- chainId,
16
- strategy: {
17
- sponsorSchema: "pay_for_user",
18
- },
19
- });
20
-
21
- // Add some rules
22
- await openfort.feeSponsorship.rules.create({
23
- type: "account_functions",
24
- policy: policy.id,
25
- });
26
-
27
- // List rules for this policy
28
- const result = await openfort.feeSponsorship.rules.list({ policy: policy.id });
29
-
30
- console.log(`Found ${result.total} rules for policy ${policy.id}:`);
31
- for (const rule of result.data) {
32
- console.log(` - ${rule.id}`);
33
- console.log(` Type: ${rule.type}`);
34
- if ("functionName" in rule && rule.functionName) {
35
- console.log(` Function: ${rule.functionName}`);
36
- }
37
- }