@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/CHANGELOG.md +6 -0
- package/README.md +29 -37
- package/dist/index.d.mts +2370 -678
- package/dist/index.d.ts +2370 -678
- package/dist/index.js +447 -271
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +419 -253
- package/dist/index.mjs.map +1 -1
- package/examples/README.md +7 -16
- package/examples/evm/accounts/getAccount.ts +0 -6
- package/examples/evm/embedded/pregenerate.ts +1 -1
- package/examples/fee-sponsorship/createPolicy.ts +24 -8
- package/examples/fee-sponsorship/disableEnablePolicy.ts +22 -9
- package/examples/fee-sponsorship/getPolicy.ts +24 -11
- package/examples/fee-sponsorship/listPolicies.ts +7 -5
- package/examples/fee-sponsorship/updatePolicy.ts +20 -7
- package/examples/iam/getSession.ts +0 -2
- package/examples/transactions/createTransactionIntent.ts +17 -11
- package/examples/transactions/estimateGas.ts +16 -14
- package/examples/transactions/getTransactionIntent.ts +16 -15
- package/openapi.json +742 -59
- package/package.json +1 -1
- package/examples/fee-sponsorship/createPolicyRule.ts +0 -43
- package/examples/fee-sponsorship/listPolicyRules.ts +0 -37
package/package.json
CHANGED
|
@@ -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
|
-
}
|