@fangorn-network/sdk 2026.7.14 → 2026.7.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/lib/cli/cli.js +28 -33
- package/lib/cli/index.d.ts +13 -13
- package/lib/config.d.ts +76 -76
- package/lib/crypto/aes.js +1 -1
- package/lib/crypto/encryption.d.ts +2 -2
- package/lib/crypto/encryption.js +3 -3
- package/lib/engine/index.js +1 -1
- package/lib/fangorn.d.ts +8 -2
- package/lib/fangorn.js +29 -13
- package/lib/index.d.ts +5 -2
- package/lib/index.js +4 -2
- package/lib/providers/storage/car.js +1 -1
- package/lib/providers/storage/index.d.ts +2 -1
- package/lib/providers/storage/index.js +2 -1
- package/lib/providers/storage/pinata.js +23 -22
- package/lib/providers/storage/signed-url.d.ts +52 -0
- package/lib/providers/storage/signed-url.js +119 -0
- package/lib/providers/storage/utils.d.ts +19 -1
- package/lib/providers/storage/utils.js +55 -1
- package/lib/types/index.d.ts +5 -0
- package/package.json +3 -1
- package/lib/node_modules/@noble/ciphers/esm/_polyval.js +0 -218
- package/lib/node_modules/@noble/ciphers/esm/aes.js +0 -261
- package/lib/node_modules/@noble/ciphers/esm/utils.js +0 -156
- package/lib/node_modules/@noble/curves/esm/abstract/curve.js +0 -299
- package/lib/node_modules/@noble/curves/esm/abstract/edwards.js +0 -532
- package/lib/node_modules/@noble/curves/esm/abstract/modular.js +0 -344
- package/lib/node_modules/@noble/curves/esm/abstract/montgomery.js +0 -137
- package/lib/node_modules/@noble/curves/esm/ed25519.js +0 -262
- package/lib/node_modules/@noble/curves/esm/utils.js +0 -150
package/lib/cli/cli.js
CHANGED
|
@@ -21,7 +21,8 @@ function loadConfig() {
|
|
|
21
21
|
const privateKey = process.env.ETH_PRIVATE_KEY;
|
|
22
22
|
const pinataJwt = process.env.PINATA_JWT;
|
|
23
23
|
const pinataGateway = process.env.PINATA_GATEWAY;
|
|
24
|
-
const
|
|
24
|
+
const accessWorkerUrl = process.env.ACCESS_WORKER_URL;
|
|
25
|
+
const signedUrlWorkerUrl = process.env.SIGNED_URL_WORKER_URL;
|
|
25
26
|
if (existsSync(CONFIG_PATH)) {
|
|
26
27
|
const stored = JSON.parse(readFileSync(CONFIG_PATH, "utf-8"));
|
|
27
28
|
_config = {
|
|
@@ -29,26 +30,24 @@ function loadConfig() {
|
|
|
29
30
|
cfg: FangornConfig,
|
|
30
31
|
pinataJwt: stored.pinataJwt,
|
|
31
32
|
pinataGateway: stored.pinataGateway,
|
|
32
|
-
|
|
33
|
+
accessWorkerUrl: stored.accessWorkerUrl ?? "",
|
|
34
|
+
signedUrlWorkerUrl: stored.signedUrlWorkerUrl ?? ""
|
|
33
35
|
};
|
|
34
36
|
return _config;
|
|
35
37
|
}
|
|
36
|
-
if (privateKey || pinataJwt || pinataGateway) {
|
|
37
|
-
|
|
38
|
-
if (!privateKey) missing.push("ETH_PRIVATE_KEY");
|
|
39
|
-
if (!pinataJwt) missing.push("PINATA_JWT");
|
|
40
|
-
if (!pinataGateway) missing.push("PINATA_GATEWAY");
|
|
41
|
-
if (missing.length > 0) throw new Error(`Incomplete environment configuration. Missing: ${missing.join(", ")}\nSet all required env vars or run \`fangorn init\` to use a config file.`);
|
|
38
|
+
if (privateKey || pinataJwt || pinataGateway || signedUrlWorkerUrl) {
|
|
39
|
+
if (!privateKey) throw new Error("Incomplete environment configuration. Missing: ETH_PRIVATE_KEY\nSet it or run `fangorn init` to use a config file.");
|
|
42
40
|
_config = {
|
|
43
41
|
privateKey,
|
|
44
42
|
cfg: FangornConfig,
|
|
45
43
|
pinataJwt: pinataJwt ?? "",
|
|
46
44
|
pinataGateway: pinataGateway ?? "",
|
|
47
|
-
|
|
45
|
+
accessWorkerUrl: accessWorkerUrl ?? "",
|
|
46
|
+
signedUrlWorkerUrl: signedUrlWorkerUrl ?? ""
|
|
48
47
|
};
|
|
49
48
|
return _config;
|
|
50
49
|
}
|
|
51
|
-
throw new Error("No configuration found. Run `fangorn init` or set
|
|
50
|
+
throw new Error("No configuration found. Run `fangorn init` or set ETH_PRIVATE_KEY\n(with no config, uploads go to Fangorn's shared Pinata account — a best-effort testnet convenience; files may be unpinned without notice. Set PINATA_JWT + PINATA_GATEWAY to use your own storage).");
|
|
52
51
|
}
|
|
53
52
|
function getAccount() {
|
|
54
53
|
if (_account) return _account;
|
|
@@ -58,12 +57,13 @@ function getAccount() {
|
|
|
58
57
|
function getFangorn() {
|
|
59
58
|
if (_fangorn) return _fangorn;
|
|
60
59
|
const cfg = loadConfig();
|
|
60
|
+
const storage = cfg.pinataJwt ? { pinata: {
|
|
61
|
+
jwt: cfg.pinataJwt,
|
|
62
|
+
gateway: cfg.pinataGateway
|
|
63
|
+
} } : { signedUrl: { workerUrl: cfg.signedUrlWorkerUrl } };
|
|
61
64
|
_fangorn = Fangorn.create({
|
|
62
65
|
privateKey: cfg.privateKey,
|
|
63
|
-
storage
|
|
64
|
-
jwt: cfg.pinataJwt,
|
|
65
|
-
gateway: cfg.pinataGateway
|
|
66
|
-
} },
|
|
66
|
+
storage,
|
|
67
67
|
domain: "localhost",
|
|
68
68
|
config: cfg.cfg
|
|
69
69
|
});
|
|
@@ -127,35 +127,30 @@ program.command("init").description("Configure your Fangorn credentials").action
|
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
129
|
handleCancel(privateKey);
|
|
130
|
-
const pinataJwt = await text({
|
|
131
|
-
message: "Pinata JWT:",
|
|
132
|
-
validate: (v) => {
|
|
133
|
-
if (!v) return "Required";
|
|
134
|
-
}
|
|
135
|
-
});
|
|
130
|
+
const pinataJwt = await text({ message: "Pinata JWT — leave blank to use Fangorn's shared Pinata account (testnet convenience; files may be unpinned without notice):" });
|
|
136
131
|
handleCancel(pinataJwt);
|
|
137
132
|
const pinataGateway = await text({
|
|
138
|
-
message: "Pinata Gateway URL:",
|
|
139
|
-
placeholder: "https://your-gateway.mypinata.cloud"
|
|
140
|
-
validate: (v) => {
|
|
141
|
-
if (!v) return "Required";
|
|
142
|
-
}
|
|
133
|
+
message: "Pinata Gateway URL (optional; blank uses a public IPFS gateway):",
|
|
134
|
+
placeholder: "https://your-gateway.mypinata.cloud"
|
|
143
135
|
});
|
|
144
136
|
handleCancel(pinataGateway);
|
|
145
|
-
const
|
|
146
|
-
message: "
|
|
147
|
-
placeholder: "https://
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
137
|
+
const accessWorkerUrl = await text({
|
|
138
|
+
message: "Access-gating worker URL (optional):",
|
|
139
|
+
placeholder: "https://access-worker.your-subdomain.workers.dev"
|
|
140
|
+
});
|
|
141
|
+
handleCancel(accessWorkerUrl);
|
|
142
|
+
const signedUrlWorkerUrl = await text({
|
|
143
|
+
message: "Presigned-URL worker URL (optional; blank uses the hosted default):",
|
|
144
|
+
placeholder: "https://pinata-url-provider.your-subdomain.workers.dev"
|
|
151
145
|
});
|
|
152
|
-
handleCancel(
|
|
146
|
+
handleCancel(signedUrlWorkerUrl);
|
|
153
147
|
const stored = {
|
|
154
148
|
privateKey,
|
|
155
149
|
chainName: "Arbitrum Sepolia",
|
|
156
150
|
pinataJwt,
|
|
157
151
|
pinataGateway,
|
|
158
|
-
|
|
152
|
+
accessWorkerUrl,
|
|
153
|
+
signedUrlWorkerUrl
|
|
159
154
|
};
|
|
160
155
|
if (!existsSync(CONFIG_DIR)) mkdirSync(CONFIG_DIR, { recursive: true });
|
|
161
156
|
writeFileSync(CONFIG_PATH, JSON.stringify(stored, null, 2), "utf-8");
|
package/lib/cli/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./cli.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as viem89 from "viem";
|
|
3
3
|
|
|
4
4
|
//#region src/cli/index.d.ts
|
|
5
5
|
declare const getChain: (chainStr: string) => {
|
|
@@ -35,17 +35,17 @@ declare const getChain: (chainStr: string) => {
|
|
|
35
35
|
testnet: true;
|
|
36
36
|
custom?: Record<string, unknown> | undefined;
|
|
37
37
|
extendSchema?: Record<string, unknown> | undefined;
|
|
38
|
-
fees?:
|
|
38
|
+
fees?: viem89.ChainFees<undefined> | undefined;
|
|
39
39
|
formatters?: undefined;
|
|
40
|
-
prepareTransactionRequest?: ((args:
|
|
40
|
+
prepareTransactionRequest?: ((args: viem89.PrepareTransactionRequestParameters, options: {
|
|
41
41
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
42
|
-
}) => Promise<
|
|
42
|
+
}) => Promise<viem89.PrepareTransactionRequestParameters>) | [fn: ((args: viem89.PrepareTransactionRequestParameters, options: {
|
|
43
43
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
44
|
-
}) => Promise<
|
|
44
|
+
}) => Promise<viem89.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
45
45
|
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
46
46
|
}] | undefined;
|
|
47
|
-
serializers?:
|
|
48
|
-
verifyHash?: ((client:
|
|
47
|
+
serializers?: viem89.ChainSerializers<undefined, viem89.TransactionSerializable> | undefined;
|
|
48
|
+
verifyHash?: ((client: viem89.Client, parameters: viem89.VerifyHashActionParameters) => Promise<viem89.VerifyHashActionReturnType>) | undefined;
|
|
49
49
|
};
|
|
50
50
|
declare const handleCancel: (value: unknown) => void;
|
|
51
51
|
declare const selectChain: () => Promise<{
|
|
@@ -81,17 +81,17 @@ declare const selectChain: () => Promise<{
|
|
|
81
81
|
testnet: true;
|
|
82
82
|
custom?: Record<string, unknown> | undefined;
|
|
83
83
|
extendSchema?: Record<string, unknown> | undefined;
|
|
84
|
-
fees?:
|
|
84
|
+
fees?: viem89.ChainFees<undefined> | undefined;
|
|
85
85
|
formatters?: undefined;
|
|
86
|
-
prepareTransactionRequest?: ((args:
|
|
86
|
+
prepareTransactionRequest?: ((args: viem89.PrepareTransactionRequestParameters, options: {
|
|
87
87
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
88
|
-
}) => Promise<
|
|
88
|
+
}) => Promise<viem89.PrepareTransactionRequestParameters>) | [fn: ((args: viem89.PrepareTransactionRequestParameters, options: {
|
|
89
89
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
90
|
-
}) => Promise<
|
|
90
|
+
}) => Promise<viem89.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
91
91
|
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
92
92
|
}] | undefined;
|
|
93
|
-
serializers?:
|
|
94
|
-
verifyHash?: ((client:
|
|
93
|
+
serializers?: viem89.ChainSerializers<undefined, viem89.TransactionSerializable> | undefined;
|
|
94
|
+
verifyHash?: ((client: viem89.Client, parameters: viem89.VerifyHashActionParameters) => Promise<viem89.VerifyHashActionReturnType>) | undefined;
|
|
95
95
|
}>;
|
|
96
96
|
declare function parseGadgetArg(raw: string): {
|
|
97
97
|
type: string;
|
package/lib/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as viem_chains0 from "viem/chains";
|
|
2
|
-
import * as
|
|
2
|
+
import * as viem0 from "viem";
|
|
3
3
|
import { Chain, Hex } from "viem";
|
|
4
4
|
import * as abitype0 from "abitype";
|
|
5
5
|
|
|
@@ -43,17 +43,17 @@ declare const SupportedNetworks: {
|
|
|
43
43
|
testnet: true;
|
|
44
44
|
custom?: Record<string, unknown> | undefined;
|
|
45
45
|
extendSchema?: Record<string, unknown> | undefined;
|
|
46
|
-
fees?:
|
|
46
|
+
fees?: viem0.ChainFees<undefined> | undefined;
|
|
47
47
|
formatters?: undefined;
|
|
48
|
-
prepareTransactionRequest?: ((args:
|
|
48
|
+
prepareTransactionRequest?: ((args: viem0.PrepareTransactionRequestParameters, options: {
|
|
49
49
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
50
|
-
}) => Promise<
|
|
50
|
+
}) => Promise<viem0.PrepareTransactionRequestParameters>) | [fn: ((args: viem0.PrepareTransactionRequestParameters, options: {
|
|
51
51
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
52
|
-
}) => Promise<
|
|
52
|
+
}) => Promise<viem0.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
53
53
|
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
54
54
|
}] | undefined;
|
|
55
|
-
serializers?:
|
|
56
|
-
verifyHash?: ((client:
|
|
55
|
+
serializers?: viem0.ChainSerializers<undefined, viem0.TransactionSerializable> | undefined;
|
|
56
|
+
verifyHash?: ((client: viem0.Client, parameters: viem0.VerifyHashActionParameters) => Promise<viem0.VerifyHashActionReturnType>) | undefined;
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
59
|
BaseSepolia: {
|
|
@@ -131,7 +131,7 @@ declare const SupportedNetworks: {
|
|
|
131
131
|
testnet: true;
|
|
132
132
|
custom?: Record<string, unknown> | undefined;
|
|
133
133
|
extendSchema?: Record<string, unknown> | undefined;
|
|
134
|
-
fees?:
|
|
134
|
+
fees?: viem0.ChainFees<undefined> | undefined;
|
|
135
135
|
formatters: {
|
|
136
136
|
readonly block: {
|
|
137
137
|
exclude: [] | undefined;
|
|
@@ -140,28 +140,28 @@ declare const SupportedNetworks: {
|
|
|
140
140
|
blobGasUsed: bigint;
|
|
141
141
|
difficulty: bigint;
|
|
142
142
|
excessBlobGas: bigint;
|
|
143
|
-
extraData:
|
|
143
|
+
extraData: viem0.Hex;
|
|
144
144
|
gasLimit: bigint;
|
|
145
145
|
gasUsed: bigint;
|
|
146
146
|
hash: `0x${string}` | null;
|
|
147
147
|
logsBloom: `0x${string}` | null;
|
|
148
148
|
miner: abitype0.Address;
|
|
149
|
-
mixHash:
|
|
149
|
+
mixHash: viem0.Hash;
|
|
150
150
|
nonce: `0x${string}` | null;
|
|
151
151
|
number: bigint | null;
|
|
152
152
|
parentBeaconBlockRoot?: `0x${string}` | undefined;
|
|
153
|
-
parentHash:
|
|
154
|
-
receiptsRoot:
|
|
155
|
-
sealFields:
|
|
156
|
-
sha3Uncles:
|
|
153
|
+
parentHash: viem0.Hash;
|
|
154
|
+
receiptsRoot: viem0.Hex;
|
|
155
|
+
sealFields: viem0.Hex[];
|
|
156
|
+
sha3Uncles: viem0.Hash;
|
|
157
157
|
size: bigint;
|
|
158
|
-
stateRoot:
|
|
158
|
+
stateRoot: viem0.Hash;
|
|
159
159
|
timestamp: bigint;
|
|
160
160
|
totalDifficulty: bigint | null;
|
|
161
161
|
transactions: `0x${string}`[] | viem_chains0.OpStackTransaction<boolean>[];
|
|
162
|
-
transactionsRoot:
|
|
163
|
-
uncles:
|
|
164
|
-
withdrawals?:
|
|
162
|
+
transactionsRoot: viem0.Hash;
|
|
163
|
+
uncles: viem0.Hash[];
|
|
164
|
+
withdrawals?: viem0.Withdrawal[] | undefined | undefined;
|
|
165
165
|
withdrawalsRoot?: `0x${string}` | undefined;
|
|
166
166
|
} & {};
|
|
167
167
|
type: "block";
|
|
@@ -173,14 +173,14 @@ declare const SupportedNetworks: {
|
|
|
173
173
|
blockNumber: bigint | null;
|
|
174
174
|
from: abitype0.Address;
|
|
175
175
|
gas: bigint;
|
|
176
|
-
hash:
|
|
177
|
-
input:
|
|
176
|
+
hash: viem0.Hash;
|
|
177
|
+
input: viem0.Hex;
|
|
178
178
|
nonce: number;
|
|
179
|
-
r:
|
|
180
|
-
s:
|
|
179
|
+
r: viem0.Hex;
|
|
180
|
+
s: viem0.Hex;
|
|
181
181
|
to: abitype0.Address | null;
|
|
182
182
|
transactionIndex: number | null;
|
|
183
|
-
typeHex:
|
|
183
|
+
typeHex: viem0.Hex | null;
|
|
184
184
|
v: bigint;
|
|
185
185
|
value: bigint;
|
|
186
186
|
yParity: number;
|
|
@@ -190,11 +190,11 @@ declare const SupportedNetworks: {
|
|
|
190
190
|
maxPriorityFeePerGas: bigint;
|
|
191
191
|
isSystemTx?: boolean;
|
|
192
192
|
mint?: bigint | undefined | undefined;
|
|
193
|
-
sourceHash:
|
|
193
|
+
sourceHash: viem0.Hex;
|
|
194
194
|
type: "deposit";
|
|
195
195
|
} | {
|
|
196
|
-
r:
|
|
197
|
-
s:
|
|
196
|
+
r: viem0.Hex;
|
|
197
|
+
s: viem0.Hex;
|
|
198
198
|
v: bigint;
|
|
199
199
|
to: abitype0.Address | null;
|
|
200
200
|
from: abitype0.Address;
|
|
@@ -203,10 +203,10 @@ declare const SupportedNetworks: {
|
|
|
203
203
|
value: bigint;
|
|
204
204
|
blockHash: `0x${string}` | null;
|
|
205
205
|
blockNumber: bigint | null;
|
|
206
|
-
hash:
|
|
207
|
-
input:
|
|
206
|
+
hash: viem0.Hash;
|
|
207
|
+
input: viem0.Hex;
|
|
208
208
|
transactionIndex: number | null;
|
|
209
|
-
typeHex:
|
|
209
|
+
typeHex: viem0.Hex | null;
|
|
210
210
|
accessList?: undefined | undefined;
|
|
211
211
|
authorizationList?: undefined | undefined;
|
|
212
212
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -225,18 +225,18 @@ declare const SupportedNetworks: {
|
|
|
225
225
|
blockNumber: bigint | null;
|
|
226
226
|
from: abitype0.Address;
|
|
227
227
|
gas: bigint;
|
|
228
|
-
hash:
|
|
229
|
-
input:
|
|
228
|
+
hash: viem0.Hash;
|
|
229
|
+
input: viem0.Hex;
|
|
230
230
|
nonce: number;
|
|
231
|
-
r:
|
|
232
|
-
s:
|
|
231
|
+
r: viem0.Hex;
|
|
232
|
+
s: viem0.Hex;
|
|
233
233
|
to: abitype0.Address | null;
|
|
234
234
|
transactionIndex: number | null;
|
|
235
|
-
typeHex:
|
|
235
|
+
typeHex: viem0.Hex | null;
|
|
236
236
|
v: bigint;
|
|
237
237
|
value: bigint;
|
|
238
238
|
yParity: number;
|
|
239
|
-
accessList:
|
|
239
|
+
accessList: viem0.AccessList;
|
|
240
240
|
authorizationList?: undefined | undefined;
|
|
241
241
|
blobVersionedHashes?: undefined | undefined;
|
|
242
242
|
chainId: number;
|
|
@@ -253,18 +253,18 @@ declare const SupportedNetworks: {
|
|
|
253
253
|
blockNumber: bigint | null;
|
|
254
254
|
from: abitype0.Address;
|
|
255
255
|
gas: bigint;
|
|
256
|
-
hash:
|
|
257
|
-
input:
|
|
256
|
+
hash: viem0.Hash;
|
|
257
|
+
input: viem0.Hex;
|
|
258
258
|
nonce: number;
|
|
259
|
-
r:
|
|
260
|
-
s:
|
|
259
|
+
r: viem0.Hex;
|
|
260
|
+
s: viem0.Hex;
|
|
261
261
|
to: abitype0.Address | null;
|
|
262
262
|
transactionIndex: number | null;
|
|
263
|
-
typeHex:
|
|
263
|
+
typeHex: viem0.Hex | null;
|
|
264
264
|
v: bigint;
|
|
265
265
|
value: bigint;
|
|
266
266
|
yParity: number;
|
|
267
|
-
accessList:
|
|
267
|
+
accessList: viem0.AccessList;
|
|
268
268
|
authorizationList?: undefined | undefined;
|
|
269
269
|
blobVersionedHashes?: undefined | undefined;
|
|
270
270
|
chainId: number;
|
|
@@ -281,20 +281,20 @@ declare const SupportedNetworks: {
|
|
|
281
281
|
blockNumber: bigint | null;
|
|
282
282
|
from: abitype0.Address;
|
|
283
283
|
gas: bigint;
|
|
284
|
-
hash:
|
|
285
|
-
input:
|
|
284
|
+
hash: viem0.Hash;
|
|
285
|
+
input: viem0.Hex;
|
|
286
286
|
nonce: number;
|
|
287
|
-
r:
|
|
288
|
-
s:
|
|
287
|
+
r: viem0.Hex;
|
|
288
|
+
s: viem0.Hex;
|
|
289
289
|
to: abitype0.Address | null;
|
|
290
290
|
transactionIndex: number | null;
|
|
291
|
-
typeHex:
|
|
291
|
+
typeHex: viem0.Hex | null;
|
|
292
292
|
v: bigint;
|
|
293
293
|
value: bigint;
|
|
294
294
|
yParity: number;
|
|
295
|
-
accessList:
|
|
295
|
+
accessList: viem0.AccessList;
|
|
296
296
|
authorizationList?: undefined | undefined;
|
|
297
|
-
blobVersionedHashes: readonly
|
|
297
|
+
blobVersionedHashes: readonly viem0.Hex[];
|
|
298
298
|
chainId: number;
|
|
299
299
|
type: "eip4844";
|
|
300
300
|
gasPrice?: undefined | undefined;
|
|
@@ -309,19 +309,19 @@ declare const SupportedNetworks: {
|
|
|
309
309
|
blockNumber: bigint | null;
|
|
310
310
|
from: abitype0.Address;
|
|
311
311
|
gas: bigint;
|
|
312
|
-
hash:
|
|
313
|
-
input:
|
|
312
|
+
hash: viem0.Hash;
|
|
313
|
+
input: viem0.Hex;
|
|
314
314
|
nonce: number;
|
|
315
|
-
r:
|
|
316
|
-
s:
|
|
315
|
+
r: viem0.Hex;
|
|
316
|
+
s: viem0.Hex;
|
|
317
317
|
to: abitype0.Address | null;
|
|
318
318
|
transactionIndex: number | null;
|
|
319
|
-
typeHex:
|
|
319
|
+
typeHex: viem0.Hex | null;
|
|
320
320
|
v: bigint;
|
|
321
321
|
value: bigint;
|
|
322
322
|
yParity: number;
|
|
323
|
-
accessList:
|
|
324
|
-
authorizationList:
|
|
323
|
+
accessList: viem0.AccessList;
|
|
324
|
+
authorizationList: viem0.SignedAuthorizationList;
|
|
325
325
|
blobVersionedHashes?: undefined | undefined;
|
|
326
326
|
chainId: number;
|
|
327
327
|
type: "eip7702";
|
|
@@ -340,7 +340,7 @@ declare const SupportedNetworks: {
|
|
|
340
340
|
format: (args: viem_chains0.OpStackRpcTransactionReceipt, action?: string | undefined) => {
|
|
341
341
|
blobGasPrice?: bigint | undefined;
|
|
342
342
|
blobGasUsed?: bigint | undefined;
|
|
343
|
-
blockHash:
|
|
343
|
+
blockHash: viem0.Hash;
|
|
344
344
|
blockNumber: bigint;
|
|
345
345
|
blockTimestamp?: bigint | undefined;
|
|
346
346
|
contractAddress: abitype0.Address | null | undefined;
|
|
@@ -348,14 +348,14 @@ declare const SupportedNetworks: {
|
|
|
348
348
|
effectiveGasPrice: bigint;
|
|
349
349
|
from: abitype0.Address;
|
|
350
350
|
gasUsed: bigint;
|
|
351
|
-
logs:
|
|
352
|
-
logsBloom:
|
|
351
|
+
logs: viem0.Log<bigint, number, false>[];
|
|
352
|
+
logsBloom: viem0.Hex;
|
|
353
353
|
root?: `0x${string}` | undefined;
|
|
354
354
|
status: "success" | "reverted";
|
|
355
355
|
to: abitype0.Address | null;
|
|
356
|
-
transactionHash:
|
|
356
|
+
transactionHash: viem0.Hash;
|
|
357
357
|
transactionIndex: number;
|
|
358
|
-
type:
|
|
358
|
+
type: viem0.TransactionType;
|
|
359
359
|
l1GasPrice: bigint | null;
|
|
360
360
|
l1GasUsed: bigint | null;
|
|
361
361
|
l1Fee: bigint | null;
|
|
@@ -364,17 +364,17 @@ declare const SupportedNetworks: {
|
|
|
364
364
|
type: "transactionReceipt";
|
|
365
365
|
};
|
|
366
366
|
};
|
|
367
|
-
prepareTransactionRequest?: ((args:
|
|
367
|
+
prepareTransactionRequest?: ((args: viem0.PrepareTransactionRequestParameters, options: {
|
|
368
368
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
369
|
-
}) => Promise<
|
|
369
|
+
}) => Promise<viem0.PrepareTransactionRequestParameters>) | [fn: ((args: viem0.PrepareTransactionRequestParameters, options: {
|
|
370
370
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
371
|
-
}) => Promise<
|
|
371
|
+
}) => Promise<viem0.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
372
372
|
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
373
373
|
}] | undefined;
|
|
374
374
|
serializers: {
|
|
375
375
|
readonly transaction: typeof viem_chains0.serializeTransactionOpStack;
|
|
376
376
|
};
|
|
377
|
-
verifyHash?: ((client:
|
|
377
|
+
verifyHash?: ((client: viem0.Client, parameters: viem0.VerifyHashActionParameters) => Promise<viem0.VerifyHashActionReturnType>) | undefined;
|
|
378
378
|
readonly network: "base-sepolia";
|
|
379
379
|
};
|
|
380
380
|
};
|
|
@@ -417,17 +417,17 @@ declare function getNetwork(name: string): {
|
|
|
417
417
|
testnet: true;
|
|
418
418
|
custom?: Record<string, unknown> | undefined;
|
|
419
419
|
extendSchema?: Record<string, unknown> | undefined;
|
|
420
|
-
fees?:
|
|
420
|
+
fees?: viem0.ChainFees<undefined> | undefined;
|
|
421
421
|
formatters?: undefined;
|
|
422
|
-
prepareTransactionRequest?: ((args:
|
|
422
|
+
prepareTransactionRequest?: ((args: viem0.PrepareTransactionRequestParameters, options: {
|
|
423
423
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
424
|
-
}) => Promise<
|
|
424
|
+
}) => Promise<viem0.PrepareTransactionRequestParameters>) | [fn: ((args: viem0.PrepareTransactionRequestParameters, options: {
|
|
425
425
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
426
|
-
}) => Promise<
|
|
426
|
+
}) => Promise<viem0.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
427
427
|
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
428
428
|
}] | undefined;
|
|
429
|
-
serializers?:
|
|
430
|
-
verifyHash?: ((client:
|
|
429
|
+
serializers?: viem0.ChainSerializers<undefined, viem0.TransactionSerializable> | undefined;
|
|
430
|
+
verifyHash?: ((client: viem0.Client, parameters: viem0.VerifyHashActionParameters) => Promise<viem0.VerifyHashActionReturnType>) | undefined;
|
|
431
431
|
};
|
|
432
432
|
interface AppConfig {
|
|
433
433
|
dataRegistryContractAddress: Hex;
|
|
@@ -471,17 +471,17 @@ declare const FangornConfig: {
|
|
|
471
471
|
testnet: true;
|
|
472
472
|
custom?: Record<string, unknown> | undefined;
|
|
473
473
|
extendSchema?: Record<string, unknown> | undefined;
|
|
474
|
-
fees?:
|
|
474
|
+
fees?: viem0.ChainFees<undefined> | undefined;
|
|
475
475
|
formatters?: undefined;
|
|
476
|
-
prepareTransactionRequest?: ((args:
|
|
476
|
+
prepareTransactionRequest?: ((args: viem0.PrepareTransactionRequestParameters, options: {
|
|
477
477
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
478
|
-
}) => Promise<
|
|
478
|
+
}) => Promise<viem0.PrepareTransactionRequestParameters>) | [fn: ((args: viem0.PrepareTransactionRequestParameters, options: {
|
|
479
479
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
480
|
-
}) => Promise<
|
|
480
|
+
}) => Promise<viem0.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
481
481
|
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
482
482
|
}] | undefined;
|
|
483
|
-
serializers?:
|
|
484
|
-
verifyHash?: ((client:
|
|
483
|
+
serializers?: viem0.ChainSerializers<undefined, viem0.TransactionSerializable> | undefined;
|
|
484
|
+
verifyHash?: ((client: viem0.Client, parameters: viem0.VerifyHashActionParameters) => Promise<viem0.VerifyHashActionReturnType>) | undefined;
|
|
485
485
|
};
|
|
486
486
|
rpcUrl: string;
|
|
487
487
|
caip2: number;
|
package/lib/crypto/aes.js
CHANGED
|
@@ -118,7 +118,7 @@ declare function buildAccessRequest(params: {
|
|
|
118
118
|
/** Unix seconds; defaults to now. Must be inside the worker's TIMESTAMP_WINDOW. */
|
|
119
119
|
timestamp?: number;
|
|
120
120
|
}): Promise<AccessRequest>;
|
|
121
|
-
|
|
121
|
+
interface DecryptHandleParams {
|
|
122
122
|
handle: HandleFieldInput;
|
|
123
123
|
/** Signs the /access request; its address is what the worker checks settlement for. */
|
|
124
124
|
signer: AccessSigner;
|
|
@@ -126,7 +126,7 @@ type DecryptHandleParams = {
|
|
|
126
126
|
nullifier: Hex;
|
|
127
127
|
/** self-hkdf-v1 only: the same 32-byte secret used to seal. */
|
|
128
128
|
ownSecret?: Uint8Array;
|
|
129
|
-
}
|
|
129
|
+
}
|
|
130
130
|
/**
|
|
131
131
|
* Resolve a {@link HandleFieldInput} back to plaintext via the worker's
|
|
132
132
|
* settlement-gated `POST /access`.
|
package/lib/crypto/encryption.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GCM_NONCE_LENGTH, aesGcmDecrypt, aesGcmEncrypt } from "./aes.js";
|
|
2
|
-
import { x25519 } from "../node_modules/@noble/curves/esm/ed25519.js";
|
|
3
2
|
import { getRandomValues } from "./rand.js";
|
|
4
3
|
import { bytesToHex, encodePacked, hexToBytes, keccak256 } from "viem";
|
|
4
|
+
import { x25519 } from "@noble/curves/ed25519";
|
|
5
5
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
6
6
|
import { hkdf } from "@noble/hashes/hkdf.js";
|
|
7
7
|
|
|
@@ -86,7 +86,7 @@ async function encryptAndUpload(params) {
|
|
|
86
86
|
},
|
|
87
87
|
body: ciphertext
|
|
88
88
|
});
|
|
89
|
-
if (!uploadRes.ok) throw new Error(`upload failed: ${uploadRes.status}`);
|
|
89
|
+
if (!uploadRes.ok) throw new Error(`upload failed: ${uploadRes.status.toString()}`);
|
|
90
90
|
const { objectKey } = await uploadRes.json();
|
|
91
91
|
return {
|
|
92
92
|
"@type": "handle",
|
|
@@ -152,7 +152,7 @@ async function decryptHandle(params) {
|
|
|
152
152
|
headers: { "Content-Type": "application/json" },
|
|
153
153
|
body: JSON.stringify(access)
|
|
154
154
|
});
|
|
155
|
-
if (!res.ok) throw new Error(`access failed: ${res.status}`);
|
|
155
|
+
if (!res.ok) throw new Error(`access failed: ${res.status.toString()}`);
|
|
156
156
|
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
157
157
|
if (gadget === GADGET_SELF_HKDF_V1) {
|
|
158
158
|
if (!params.ownSecret) throw new Error(`${gadget} requires ownSecret to decrypt`);
|
package/lib/engine/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { buildPages, decodeBlock, encodeBlock, readPages } from "./graph.js";
|
|
2
1
|
import { packCar, readCar } from "./car.js";
|
|
2
|
+
import { buildPages, decodeBlock, encodeBlock, readPages } from "./graph.js";
|
|
3
3
|
import { CID } from "multiformats/cid";
|
|
4
4
|
import { sha256 } from "multiformats/hashes/sha2";
|
|
5
5
|
import * as Digest from "multiformats/hashes/digest";
|
package/lib/fangorn.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { DataRegistryClient } from "./contracts/data-registry/index.js";
|
|
|
3
3
|
import "./contracts/index.js";
|
|
4
4
|
import { MetadataStorage } from "./providers/storage/types.js";
|
|
5
5
|
import { CommitDiff, FangornEngine, MetagraphRegistry, NamespaceContents, NamespaceDiff } from "./engine/index.js";
|
|
6
|
-
import { FangornCreateOptions } from "./types/index.js";
|
|
6
|
+
import { FangornCreateOptions, StorageConfig } from "./types/index.js";
|
|
7
7
|
import { Hex, WalletClient } from "viem";
|
|
8
8
|
|
|
9
9
|
//#region src/fangorn.d.ts
|
|
@@ -37,7 +37,7 @@ interface SubscribeOptions {
|
|
|
37
37
|
declare class Fangorn {
|
|
38
38
|
private readonly ctx;
|
|
39
39
|
private _engine;
|
|
40
|
-
private _metagraph;
|
|
40
|
+
private readonly _metagraph;
|
|
41
41
|
private constructor();
|
|
42
42
|
get engine(): FangornEngine;
|
|
43
43
|
get metagraph(): MetagraphRegistry;
|
|
@@ -159,6 +159,12 @@ declare class Fangorn {
|
|
|
159
159
|
getConfig(): AppConfig;
|
|
160
160
|
getDataRegistry(): DataRegistryClient;
|
|
161
161
|
getStorage(): MetadataStorage;
|
|
162
|
+
/**
|
|
163
|
+
* Swap the storage backend at runtime — e.g. move from access-worker signed
|
|
164
|
+
* URLs to your own Pinata JWT (or back). Rebuilds the engine on next use so it
|
|
165
|
+
* picks up the new backend.
|
|
166
|
+
*/
|
|
167
|
+
setStorage(storage: StorageConfig): void;
|
|
162
168
|
getWalletClient(): WalletClient;
|
|
163
169
|
getAddress(): Hex;
|
|
164
170
|
}
|