@openfort/openfort-node 0.7.0 → 0.7.2
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 +12 -0
- package/dist/index.d.mts +499 -389
- package/dist/index.d.ts +499 -389
- package/dist/index.js +193 -147
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +185 -143
- package/dist/index.mjs.map +1 -1
- package/examples/.env.example +1 -1
- package/examples/README.md +20 -17
- package/examples/contracts/createContract.ts +3 -3
- package/examples/{iam/pregenerateUser.ts → evm/embedded/pregenerate.ts} +2 -2
- package/examples/exchange/createSwap.ts +2 -1
- package/examples/transactions/createTransactionIntent.ts +13 -8
- package/examples/transactions/estimateGas.ts +14 -4
- package/examples/transactions/getTransactionIntent.ts +14 -3
- package/openapi-auth.json +86 -53
- package/openapi.json +336 -52
- package/package.json +2 -2
- package/examples/contracts/readContract.ts +0 -29
package/examples/.env.example
CHANGED
|
@@ -10,7 +10,7 @@ OPENFORT_PUBLISHABLE_KEY=pk_test_...
|
|
|
10
10
|
# Chain ID for EVM operations (e.g., 80002 for Amoy, 84532 for Base Sepolia)
|
|
11
11
|
CHAIN_ID=80002
|
|
12
12
|
|
|
13
|
-
# Shield Configuration (required for
|
|
13
|
+
# Shield Configuration (required for evm/embedded/pregenerate.ts)
|
|
14
14
|
SHIELD_API_KEY=your_shield_api_key
|
|
15
15
|
SHIELD_API_SECRET=your_shield_api_secret
|
|
16
16
|
SHIELD_ENCRYPTION_SHARE=your_encryption_share
|
package/examples/README.md
CHANGED
|
@@ -73,6 +73,16 @@ pnpm example evm/accounts/createAccount.ts
|
|
|
73
73
|
| `signHash.ts` | Sign a raw hash |
|
|
74
74
|
| `signTransaction.ts` | Sign a transaction |
|
|
75
75
|
|
|
76
|
+
#### Embedded Wallets (`evm/embedded/`)
|
|
77
|
+
| Example | Description |
|
|
78
|
+
| ---------------- | ---------------------------------------- |
|
|
79
|
+
| `pregenerate.ts` | Pre-generate a user with embedded wallet |
|
|
80
|
+
|
|
81
|
+
> **Note:** The `pregenerate.ts` example requires Shield configuration. See `.env.example` for required environment variables:
|
|
82
|
+
> - `SHIELD_API_KEY`
|
|
83
|
+
> - `SHIELD_API_SECRET`
|
|
84
|
+
> - `SHIELD_ENCRYPTION_SHARE`
|
|
85
|
+
|
|
76
86
|
### Solana Wallet Examples
|
|
77
87
|
|
|
78
88
|
#### Accounts (`solana/accounts/`)
|
|
@@ -105,11 +115,10 @@ pnpm example evm/accounts/createAccount.ts
|
|
|
105
115
|
|
|
106
116
|
### Contracts
|
|
107
117
|
|
|
108
|
-
| Example | Description
|
|
109
|
-
| ----------------------------- |
|
|
110
|
-
| `contracts/createContract.ts` | Register a contract
|
|
111
|
-
| `contracts/listContracts.ts` | List all contracts
|
|
112
|
-
| `contracts/readContract.ts` | Read data from a contract |
|
|
118
|
+
| Example | Description |
|
|
119
|
+
| ----------------------------- | ------------------- |
|
|
120
|
+
| `contracts/createContract.ts` | Register a contract |
|
|
121
|
+
| `contracts/listContracts.ts` | List all contracts |
|
|
113
122
|
|
|
114
123
|
### Transaction Intents
|
|
115
124
|
|
|
@@ -129,18 +138,12 @@ pnpm example evm/accounts/createAccount.ts
|
|
|
129
138
|
|
|
130
139
|
### IAM (Identity & Access Management)
|
|
131
140
|
|
|
132
|
-
| Example
|
|
133
|
-
|
|
|
134
|
-
| `iam/listUsers.ts`
|
|
135
|
-
| `iam/getUser.ts`
|
|
136
|
-
| `iam/deleteUser.ts`
|
|
137
|
-
| `iam/
|
|
138
|
-
| `iam/getSession.ts` | Verify auth token server-side |
|
|
139
|
-
|
|
140
|
-
> **Note:** The `pregenerateUser.ts` example requires additional Shield configuration. See `.env.example` for the required environment variables:
|
|
141
|
-
> - `SHIELD_API_KEY`
|
|
142
|
-
> - `SHIELD_API_SECRET`
|
|
143
|
-
> - `SHIELD_ENCRYPTION_SHARE`
|
|
141
|
+
| Example | Description |
|
|
142
|
+
| ------------------- | ----------------------------- |
|
|
143
|
+
| `iam/listUsers.ts` | List all authenticated users |
|
|
144
|
+
| `iam/getUser.ts` | Get a user by ID |
|
|
145
|
+
| `iam/deleteUser.ts` | Delete a user |
|
|
146
|
+
| `iam/getSession.ts` | Verify auth token server-side |
|
|
144
147
|
|
|
145
148
|
### Webhooks
|
|
146
149
|
|
|
@@ -11,11 +11,11 @@ const chainId = Number(process.env.CHAIN_ID) || 80002;
|
|
|
11
11
|
|
|
12
12
|
// Create a contract reference
|
|
13
13
|
const contract = await openfort.contracts.create({
|
|
14
|
-
name: "My
|
|
14
|
+
name: "My Token Contract",
|
|
15
15
|
chainId,
|
|
16
|
-
address: "
|
|
16
|
+
address: "0xbabe0001489722187FbaF0689C47B2f5E97545C5",
|
|
17
17
|
// Optional: provide ABI for function name validation
|
|
18
|
-
// abi: [
|
|
18
|
+
// abi: []
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
console.log("Created contract:");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Usage: npx tsx
|
|
1
|
+
// Usage: npx tsx evm/embedded/pregenerate.ts
|
|
2
2
|
|
|
3
3
|
import Openfort, { ShieldAuthProvider } from "@openfort/openfort-node";
|
|
4
4
|
import "dotenv/config";
|
|
@@ -9,7 +9,7 @@ const openfort = new Openfort(process.env.OPENFORT_API_KEY!, {
|
|
|
9
9
|
|
|
10
10
|
// Pre-generate a user with an embedded wallet
|
|
11
11
|
// This creates the user and wallet before they authenticate
|
|
12
|
-
const result = await openfort.
|
|
12
|
+
const result = await openfort.accounts.evm.embedded.pregenerate(
|
|
13
13
|
{
|
|
14
14
|
email: "jaume+1@openfort.xyz",
|
|
15
15
|
accountType: "Externally Owned Account"
|
|
@@ -7,7 +7,7 @@ const openfort = new Openfort(process.env.OPENFORT_API_KEY!, {
|
|
|
7
7
|
basePath: process.env.OPENFORT_BASE_URL,
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
const chainId =
|
|
10
|
+
const chainId = 84532; // Should be the chain which supports swaps
|
|
11
11
|
|
|
12
12
|
// Create an account (V1 legacy API)
|
|
13
13
|
const account = await openfort.accounts.v1.create({
|
|
@@ -30,6 +30,7 @@ await openfort.policyRules.create({
|
|
|
30
30
|
|
|
31
31
|
console.log("Account address:", account.address);
|
|
32
32
|
console.log("Policy ID:", policy.id);
|
|
33
|
+
console.log("Account ID:", account.id);
|
|
33
34
|
|
|
34
35
|
// Create a swap transaction
|
|
35
36
|
// Note: Token addresses and amounts will vary by network
|
|
@@ -9,11 +9,6 @@ const openfort = new Openfort(process.env.OPENFORT_API_KEY!, {
|
|
|
9
9
|
|
|
10
10
|
const chainId = Number(process.env.CHAIN_ID) || 80002;
|
|
11
11
|
|
|
12
|
-
// Create an account (V1 legacy API)
|
|
13
|
-
const account = await openfort.accounts.v1.create({
|
|
14
|
-
chainId,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
12
|
// Create a policy for gas sponsorship
|
|
18
13
|
const policy = await openfort.policies.create({
|
|
19
14
|
name: `TxPolicy-${Date.now()}`,
|
|
@@ -23,9 +18,19 @@ const policy = await openfort.policies.create({
|
|
|
23
18
|
},
|
|
24
19
|
});
|
|
25
20
|
|
|
21
|
+
const contract = await openfort.contracts.create({
|
|
22
|
+
name: "My Token Contract",
|
|
23
|
+
chainId,
|
|
24
|
+
address: "0xbabe0001489722187FbaF0689C47B2f5E97545C5",
|
|
25
|
+
// Optional: provide ABI for function name validation
|
|
26
|
+
// abi: [...]
|
|
27
|
+
});
|
|
28
|
+
|
|
26
29
|
// Create a policy rule to allow all account functions
|
|
27
30
|
await openfort.policyRules.create({
|
|
28
|
-
type: "
|
|
31
|
+
type: "contract_functions",
|
|
32
|
+
functionName: "All functions",
|
|
33
|
+
wildcard: true,
|
|
29
34
|
policy: policy.id,
|
|
30
35
|
});
|
|
31
36
|
|
|
@@ -35,9 +40,9 @@ const transactionIntent = await openfort.transactionIntents.create({
|
|
|
35
40
|
policy: policy.id,
|
|
36
41
|
interactions: [
|
|
37
42
|
{
|
|
38
|
-
contract:
|
|
43
|
+
contract: contract.id,
|
|
39
44
|
functionName: "mint",
|
|
40
|
-
functionArgs: [
|
|
45
|
+
functionArgs: ['0x662D24Bf7Ea2dD6a7D0935F680a6056b94fE934d', '123'],
|
|
41
46
|
},
|
|
42
47
|
],
|
|
43
48
|
});
|
|
@@ -23,20 +23,30 @@ const policy = await openfort.policies.create({
|
|
|
23
23
|
},
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
+
const contract = await openfort.contracts.create({
|
|
27
|
+
name: "My Token Contract",
|
|
28
|
+
chainId,
|
|
29
|
+
address: "0xbabe0001489722187FbaF0689C47B2f5E97545C5",
|
|
30
|
+
// Optional: provide ABI for function name validation
|
|
31
|
+
// abi: [...]
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Create a policy rule to allow all account functions
|
|
26
35
|
await openfort.policyRules.create({
|
|
27
|
-
type: "
|
|
36
|
+
type: "contract_functions",
|
|
37
|
+
functionName: "All functions",
|
|
38
|
+
wildcard: true,
|
|
28
39
|
policy: policy.id,
|
|
29
40
|
});
|
|
30
|
-
|
|
31
41
|
// Define transaction intent request
|
|
32
42
|
const transactionIntentRequest = {
|
|
33
43
|
chainId,
|
|
34
44
|
policy: policy.id,
|
|
35
45
|
interactions: [
|
|
36
46
|
{
|
|
37
|
-
contract:
|
|
47
|
+
contract: contract.id,
|
|
38
48
|
functionName: "mint",
|
|
39
|
-
functionArgs: [
|
|
49
|
+
functionArgs: ['0x662D24Bf7Ea2dD6a7D0935F680a6056b94fE934d', '123'],
|
|
40
50
|
},
|
|
41
51
|
],
|
|
42
52
|
};
|
|
@@ -23,8 +23,19 @@ const policy = await openfort.policies.create({
|
|
|
23
23
|
},
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
+
const contract = await openfort.contracts.create({
|
|
27
|
+
name: "My Token Contract",
|
|
28
|
+
chainId,
|
|
29
|
+
address: "0xbabe0001489722187FbaF0689C47B2f5E97545C5",
|
|
30
|
+
// Optional: provide ABI for function name validation
|
|
31
|
+
// abi: [...]
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Create a policy rule to allow all account functions
|
|
26
35
|
await openfort.policyRules.create({
|
|
27
|
-
type: "
|
|
36
|
+
type: "contract_functions",
|
|
37
|
+
functionName: "All functions",
|
|
38
|
+
wildcard: true,
|
|
28
39
|
policy: policy.id,
|
|
29
40
|
});
|
|
30
41
|
|
|
@@ -34,9 +45,9 @@ const created = await openfort.transactionIntents.create({
|
|
|
34
45
|
policy: policy.id,
|
|
35
46
|
interactions: [
|
|
36
47
|
{
|
|
37
|
-
contract:
|
|
48
|
+
contract: contract.id,
|
|
38
49
|
functionName: "mint",
|
|
39
|
-
functionArgs: [
|
|
50
|
+
functionArgs: ['0x662D24Bf7Ea2dD6a7D0935F680a6056b94fE934d', '123'],
|
|
40
51
|
},
|
|
41
52
|
],
|
|
42
53
|
});
|