@opendatalabs/vana-sdk 3.4.0 → 3.4.1-canary.a244135
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/dist/index.browser.d.ts +6 -3
- package/dist/index.browser.js +381 -128
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +403 -133
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +6 -3
- package/dist/index.node.js +381 -128
- package/dist/index.node.js.map +4 -4
- package/dist/protocol/data-point-status.cjs +80 -0
- package/dist/protocol/data-point-status.cjs.map +1 -0
- package/dist/protocol/data-point-status.d.ts +34 -0
- package/dist/protocol/data-point-status.js +51 -0
- package/dist/protocol/data-point-status.js.map +1 -0
- package/dist/protocol/data-point-status.test.d.ts +1 -0
- package/dist/protocol/eip712.cjs +53 -31
- package/dist/protocol/eip712.cjs.map +1 -1
- package/dist/protocol/eip712.d.ts +98 -43
- package/dist/protocol/eip712.js +47 -27
- package/dist/protocol/eip712.js.map +1 -1
- package/dist/protocol/escrow-deposit.cjs +89 -0
- package/dist/protocol/escrow-deposit.cjs.map +1 -0
- package/dist/protocol/escrow-deposit.d.ts +47 -0
- package/dist/protocol/escrow-deposit.js +60 -0
- package/dist/protocol/escrow-deposit.js.map +1 -0
- package/dist/protocol/escrow-deposit.test.d.ts +1 -0
- package/dist/protocol/escrow-flow.test.d.ts +21 -0
- package/dist/protocol/fee-registry.cjs +116 -0
- package/dist/protocol/fee-registry.cjs.map +1 -0
- package/dist/protocol/fee-registry.d.ts +151 -0
- package/dist/protocol/fee-registry.js +89 -0
- package/dist/protocol/fee-registry.js.map +1 -0
- package/dist/protocol/fee-registry.test.d.ts +1 -0
- package/dist/protocol/gateway.cjs +110 -38
- package/dist/protocol/gateway.cjs.map +1 -1
- package/dist/protocol/gateway.d.ts +238 -56
- package/dist/protocol/gateway.js +110 -38
- package/dist/protocol/gateway.js.map +1 -1
- package/dist/protocol/grants.cjs +27 -64
- package/dist/protocol/grants.cjs.map +1 -1
- package/dist/protocol/grants.d.ts +6 -13
- package/dist/protocol/grants.js +27 -63
- package/dist/protocol/grants.js.map +1 -1
- package/package.json +3 -2
package/dist/index.browser.js
CHANGED
|
@@ -31882,6 +31882,7 @@ async function verifyWeb3Signed(params) {
|
|
|
31882
31882
|
// src/protocol/eip712.ts
|
|
31883
31883
|
var DOMAIN_NAME = "Vana Data Portability";
|
|
31884
31884
|
var DOMAIN_VERSION = "1";
|
|
31885
|
+
var NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
|
|
31885
31886
|
function buildDomain(chainId, verifyingContract) {
|
|
31886
31887
|
return {
|
|
31887
31888
|
name: DOMAIN_NAME,
|
|
@@ -31890,13 +31891,7 @@ function buildDomain(chainId, verifyingContract) {
|
|
|
31890
31891
|
verifyingContract
|
|
31891
31892
|
};
|
|
31892
31893
|
}
|
|
31893
|
-
function
|
|
31894
|
-
return buildDomain(
|
|
31895
|
-
config.chainId,
|
|
31896
|
-
config.contracts.dataRegistry
|
|
31897
|
-
);
|
|
31898
|
-
}
|
|
31899
|
-
function fileDeletionDomain(config) {
|
|
31894
|
+
function dataRegistryDomain(config) {
|
|
31900
31895
|
return buildDomain(
|
|
31901
31896
|
config.chainId,
|
|
31902
31897
|
config.contracts.dataRegistry
|
|
@@ -31926,31 +31921,26 @@ function builderRegistrationDomain(config) {
|
|
|
31926
31921
|
config.contracts.dataPortabilityGrantees
|
|
31927
31922
|
);
|
|
31928
31923
|
}
|
|
31929
|
-
|
|
31930
|
-
|
|
31931
|
-
|
|
31932
|
-
|
|
31933
|
-
|
|
31934
|
-
|
|
31935
|
-
};
|
|
31936
|
-
var FILE_DELETION_TYPES = {
|
|
31937
|
-
FileDeletion: [
|
|
31938
|
-
{ name: "ownerAddress", type: "address" },
|
|
31939
|
-
{ name: "fileId", type: "bytes32" }
|
|
31940
|
-
]
|
|
31941
|
-
};
|
|
31924
|
+
function escrowPaymentDomain(config) {
|
|
31925
|
+
return buildDomain(
|
|
31926
|
+
config.chainId,
|
|
31927
|
+
config.contracts.dataPortabilityEscrow
|
|
31928
|
+
);
|
|
31929
|
+
}
|
|
31942
31930
|
var GRANT_REGISTRATION_TYPES = {
|
|
31943
31931
|
GrantRegistration: [
|
|
31944
31932
|
{ name: "grantorAddress", type: "address" },
|
|
31945
31933
|
{ name: "granteeId", type: "bytes32" },
|
|
31946
|
-
{ name: "
|
|
31947
|
-
{ name: "
|
|
31934
|
+
{ name: "scopes", type: "string[]" },
|
|
31935
|
+
{ name: "grantVersion", type: "uint256" },
|
|
31936
|
+
{ name: "expiresAt", type: "uint256" }
|
|
31948
31937
|
]
|
|
31949
31938
|
};
|
|
31950
31939
|
var GRANT_REVOCATION_TYPES = {
|
|
31951
31940
|
GrantRevocation: [
|
|
31952
31941
|
{ name: "grantorAddress", type: "address" },
|
|
31953
|
-
{ name: "grantId", type: "bytes32" }
|
|
31942
|
+
{ name: "grantId", type: "bytes32" },
|
|
31943
|
+
{ name: "grantVersion", type: "uint256" }
|
|
31954
31944
|
]
|
|
31955
31945
|
};
|
|
31956
31946
|
var SERVER_REGISTRATION_TYPES = {
|
|
@@ -31969,6 +31959,34 @@ var BUILDER_REGISTRATION_TYPES = {
|
|
|
31969
31959
|
{ name: "appUrl", type: "string" }
|
|
31970
31960
|
]
|
|
31971
31961
|
};
|
|
31962
|
+
var GENERIC_PAYMENT_TYPES = {
|
|
31963
|
+
GenericPayment: [
|
|
31964
|
+
{ name: "payerAddress", type: "address" },
|
|
31965
|
+
{ name: "opType", type: "string" },
|
|
31966
|
+
{ name: "opId", type: "bytes32" },
|
|
31967
|
+
{ name: "asset", type: "address" },
|
|
31968
|
+
{ name: "amount", type: "uint256" },
|
|
31969
|
+
{ name: "paymentNonce", type: "uint256" }
|
|
31970
|
+
]
|
|
31971
|
+
};
|
|
31972
|
+
var ADD_DATA_TYPES = {
|
|
31973
|
+
AddData: [
|
|
31974
|
+
{ name: "ownerAddress", type: "address" },
|
|
31975
|
+
{ name: "scope", type: "string" },
|
|
31976
|
+
{ name: "dataHash", type: "bytes32" },
|
|
31977
|
+
{ name: "metadataHash", type: "bytes32" },
|
|
31978
|
+
{ name: "expectedVersion", type: "uint256" }
|
|
31979
|
+
]
|
|
31980
|
+
};
|
|
31981
|
+
var RECORD_DATA_ACCESS_TYPES = {
|
|
31982
|
+
RecordDataAccess: [
|
|
31983
|
+
{ name: "ownerAddress", type: "address" },
|
|
31984
|
+
{ name: "scope", type: "string" },
|
|
31985
|
+
{ name: "version", type: "uint256" },
|
|
31986
|
+
{ name: "accessor", type: "address" },
|
|
31987
|
+
{ name: "recordId", type: "bytes32" }
|
|
31988
|
+
]
|
|
31989
|
+
};
|
|
31972
31990
|
|
|
31973
31991
|
// src/protocol/personal-server-registration.ts
|
|
31974
31992
|
import {
|
|
@@ -32410,67 +32428,34 @@ function isDataPortabilityGatewayConfig(value) {
|
|
|
32410
32428
|
return false;
|
|
32411
32429
|
}
|
|
32412
32430
|
const c = contracts;
|
|
32413
|
-
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]);
|
|
32431
|
+
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]) && isHexString(c["dataPortabilityEscrow"]) && isHexString(c["feeRegistry"]);
|
|
32414
32432
|
}
|
|
32415
|
-
function
|
|
32416
|
-
let parsed;
|
|
32433
|
+
function toUint256(value) {
|
|
32417
32434
|
try {
|
|
32418
|
-
|
|
32419
|
-
|
|
32420
|
-
|
|
32421
|
-
|
|
32422
|
-
|
|
32423
|
-
return
|
|
32424
|
-
}
|
|
32425
|
-
const value = parsed;
|
|
32426
|
-
if (!Array.isArray(value["scopes"]) || value["scopes"].length === 0) {
|
|
32427
|
-
return null;
|
|
32428
|
-
}
|
|
32429
|
-
if (!value["scopes"].every((scope) => typeof scope === "string")) {
|
|
32430
|
-
return null;
|
|
32431
|
-
}
|
|
32432
|
-
if (typeof value["expiresAt"] !== "number" || !Number.isFinite(value["expiresAt"])) {
|
|
32433
|
-
return null;
|
|
32434
|
-
}
|
|
32435
|
-
if (value["user"] !== void 0 && !isHexString(value["user"])) {
|
|
32436
|
-
return null;
|
|
32437
|
-
}
|
|
32438
|
-
if (value["builder"] !== void 0 && !isHexString(value["builder"])) {
|
|
32439
|
-
return null;
|
|
32440
|
-
}
|
|
32441
|
-
if (value["nonce"] !== void 0 && (typeof value["nonce"] !== "number" || !Number.isFinite(value["nonce"]))) {
|
|
32442
|
-
return null;
|
|
32443
|
-
}
|
|
32444
|
-
return {
|
|
32445
|
-
user: value["user"],
|
|
32446
|
-
builder: value["builder"],
|
|
32447
|
-
scopes: value["scopes"],
|
|
32448
|
-
expiresAt: value["expiresAt"],
|
|
32449
|
-
nonce: value["nonce"]
|
|
32450
|
-
};
|
|
32451
|
-
}
|
|
32452
|
-
function parseFileIds(fileIds) {
|
|
32453
|
-
try {
|
|
32454
|
-
const values = (fileIds ?? []).map((fileId) => BigInt(fileId));
|
|
32455
|
-
return {
|
|
32456
|
-
values,
|
|
32457
|
-
display: values.map((fileId) => fileId.toString())
|
|
32458
|
-
};
|
|
32435
|
+
if (typeof value === "number" && !Number.isSafeInteger(value)) {
|
|
32436
|
+
return null;
|
|
32437
|
+
}
|
|
32438
|
+
const big = typeof value === "bigint" ? value : BigInt(value);
|
|
32439
|
+
if (big < 0n) return null;
|
|
32440
|
+
return big;
|
|
32459
32441
|
} catch {
|
|
32460
32442
|
return null;
|
|
32461
32443
|
}
|
|
32462
32444
|
}
|
|
32463
32445
|
async function verifyGrantRegistration(input) {
|
|
32464
|
-
|
|
32465
|
-
|
|
32466
|
-
|
|
32467
|
-
|
|
32468
|
-
|
|
32469
|
-
};
|
|
32446
|
+
if (!Array.isArray(input.scopes) || input.scopes.length === 0) {
|
|
32447
|
+
return { valid: false, error: "scopes must be a non-empty array" };
|
|
32448
|
+
}
|
|
32449
|
+
if (!input.scopes.every((scope) => typeof scope === "string")) {
|
|
32450
|
+
return { valid: false, error: "scopes must contain only strings" };
|
|
32470
32451
|
}
|
|
32471
|
-
const
|
|
32472
|
-
if (
|
|
32473
|
-
return { valid: false, error: "
|
|
32452
|
+
const grantVersion = toUint256(input.grantVersion);
|
|
32453
|
+
if (grantVersion === null || grantVersion < 1n) {
|
|
32454
|
+
return { valid: false, error: "grantVersion must be a uint256 >= 1" };
|
|
32455
|
+
}
|
|
32456
|
+
const expiresAt = toUint256(input.expiresAt);
|
|
32457
|
+
if (expiresAt === null) {
|
|
32458
|
+
return { valid: false, error: "expiresAt must be a non-negative uint256" };
|
|
32474
32459
|
}
|
|
32475
32460
|
let valid;
|
|
32476
32461
|
try {
|
|
@@ -32482,8 +32467,9 @@ async function verifyGrantRegistration(input) {
|
|
|
32482
32467
|
message: {
|
|
32483
32468
|
grantorAddress: input.grantorAddress,
|
|
32484
32469
|
granteeId: input.granteeId,
|
|
32485
|
-
|
|
32486
|
-
|
|
32470
|
+
scopes: input.scopes,
|
|
32471
|
+
grantVersion,
|
|
32472
|
+
expiresAt
|
|
32487
32473
|
},
|
|
32488
32474
|
signature: input.signature
|
|
32489
32475
|
});
|
|
@@ -32494,19 +32480,197 @@ async function verifyGrantRegistration(input) {
|
|
|
32494
32480
|
return { valid: false, error: "Grant signature does not match grantor" };
|
|
32495
32481
|
}
|
|
32496
32482
|
const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
|
|
32497
|
-
if (
|
|
32483
|
+
if (expiresAt > 0n && expiresAt < BigInt(nowSeconds)) {
|
|
32498
32484
|
return { valid: false, error: "Grant has expired" };
|
|
32499
32485
|
}
|
|
32500
|
-
if (payload.user !== void 0 && payload.user.toLowerCase() !== input.grantorAddress.toLowerCase()) {
|
|
32501
|
-
return { valid: false, error: "Grant user does not match grantorAddress" };
|
|
32502
|
-
}
|
|
32503
32486
|
return {
|
|
32504
32487
|
valid: true,
|
|
32505
32488
|
grantorAddress: input.grantorAddress,
|
|
32506
32489
|
granteeId: input.granteeId,
|
|
32507
|
-
|
|
32508
|
-
|
|
32509
|
-
|
|
32490
|
+
scopes: input.scopes,
|
|
32491
|
+
grantVersion: grantVersion.toString(),
|
|
32492
|
+
expiresAt: expiresAt.toString()
|
|
32493
|
+
};
|
|
32494
|
+
}
|
|
32495
|
+
|
|
32496
|
+
// src/protocol/escrow-deposit.ts
|
|
32497
|
+
import { encodeFunctionData } from "viem";
|
|
32498
|
+
var ESCROW_DEPOSIT_ABI = [
|
|
32499
|
+
{
|
|
32500
|
+
type: "function",
|
|
32501
|
+
name: "depositNative",
|
|
32502
|
+
stateMutability: "payable",
|
|
32503
|
+
inputs: [{ name: "account", type: "address" }],
|
|
32504
|
+
outputs: []
|
|
32505
|
+
},
|
|
32506
|
+
{
|
|
32507
|
+
type: "function",
|
|
32508
|
+
name: "depositToken",
|
|
32509
|
+
stateMutability: "nonpayable",
|
|
32510
|
+
inputs: [
|
|
32511
|
+
{ name: "account", type: "address" },
|
|
32512
|
+
{ name: "token", type: "address" },
|
|
32513
|
+
{ name: "amount", type: "uint256" }
|
|
32514
|
+
],
|
|
32515
|
+
outputs: []
|
|
32516
|
+
}
|
|
32517
|
+
];
|
|
32518
|
+
function escrowContractAddress(config) {
|
|
32519
|
+
return config.contracts.dataPortabilityEscrow;
|
|
32520
|
+
}
|
|
32521
|
+
function encodeDepositNativeData(input) {
|
|
32522
|
+
return encodeFunctionData({
|
|
32523
|
+
abi: ESCROW_DEPOSIT_ABI,
|
|
32524
|
+
functionName: "depositNative",
|
|
32525
|
+
args: [input.account]
|
|
32526
|
+
});
|
|
32527
|
+
}
|
|
32528
|
+
function encodeDepositTokenData(input) {
|
|
32529
|
+
return encodeFunctionData({
|
|
32530
|
+
abi: ESCROW_DEPOSIT_ABI,
|
|
32531
|
+
functionName: "depositToken",
|
|
32532
|
+
args: [input.account, input.token, input.amount]
|
|
32533
|
+
});
|
|
32534
|
+
}
|
|
32535
|
+
function buildDepositNativeRequest(config, input) {
|
|
32536
|
+
return {
|
|
32537
|
+
to: escrowContractAddress(config),
|
|
32538
|
+
data: encodeDepositNativeData({ account: input.account }),
|
|
32539
|
+
value: input.amount
|
|
32540
|
+
};
|
|
32541
|
+
}
|
|
32542
|
+
function buildDepositTokenRequest(config, input) {
|
|
32543
|
+
return {
|
|
32544
|
+
to: escrowContractAddress(config),
|
|
32545
|
+
data: encodeDepositTokenData(input)
|
|
32546
|
+
};
|
|
32547
|
+
}
|
|
32548
|
+
|
|
32549
|
+
// src/protocol/data-point-status.ts
|
|
32550
|
+
import { encodeFunctionData as encodeFunctionData2 } from "viem";
|
|
32551
|
+
var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
|
|
32552
|
+
DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
|
|
32553
|
+
DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
|
|
32554
|
+
DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
|
|
32555
|
+
DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
|
|
32556
|
+
return DataPointStatus2;
|
|
32557
|
+
})(DataPointStatus || {});
|
|
32558
|
+
var DATA_REGISTRY_STATUS_ABI = [
|
|
32559
|
+
{
|
|
32560
|
+
type: "function",
|
|
32561
|
+
name: "setStatus",
|
|
32562
|
+
stateMutability: "nonpayable",
|
|
32563
|
+
inputs: [
|
|
32564
|
+
{ name: "scope", type: "string" },
|
|
32565
|
+
{ name: "newStatus", type: "uint8" }
|
|
32566
|
+
],
|
|
32567
|
+
outputs: []
|
|
32568
|
+
}
|
|
32569
|
+
];
|
|
32570
|
+
function dataRegistryContractAddress(config) {
|
|
32571
|
+
return config.contracts.dataRegistry;
|
|
32572
|
+
}
|
|
32573
|
+
function encodeSetDataPointStatusData(input) {
|
|
32574
|
+
return encodeFunctionData2({
|
|
32575
|
+
abi: DATA_REGISTRY_STATUS_ABI,
|
|
32576
|
+
functionName: "setStatus",
|
|
32577
|
+
args: [input.scope, input.status]
|
|
32578
|
+
});
|
|
32579
|
+
}
|
|
32580
|
+
function buildSetDataPointStatusRequest(config, input) {
|
|
32581
|
+
return {
|
|
32582
|
+
to: dataRegistryContractAddress(config),
|
|
32583
|
+
data: encodeSetDataPointStatusData(input)
|
|
32584
|
+
};
|
|
32585
|
+
}
|
|
32586
|
+
function buildMarkDataPointUnavailableRequest(config, input) {
|
|
32587
|
+
return buildSetDataPointStatusRequest(config, {
|
|
32588
|
+
scope: input.scope,
|
|
32589
|
+
status: 3 /* Unavailable */
|
|
32590
|
+
});
|
|
32591
|
+
}
|
|
32592
|
+
|
|
32593
|
+
// src/protocol/fee-registry.ts
|
|
32594
|
+
import { parseAbi } from "viem";
|
|
32595
|
+
var FEE_REGISTRY_ABI = parseAbi([
|
|
32596
|
+
"struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
|
|
32597
|
+
"function fees(bytes32 operation) view returns (Fee)",
|
|
32598
|
+
"function operationKey(string name) pure returns (bytes32)"
|
|
32599
|
+
]);
|
|
32600
|
+
var REGISTRATION_KIND_FOR_OP = {
|
|
32601
|
+
grant: "grant_registration",
|
|
32602
|
+
data: "data_registration",
|
|
32603
|
+
server: "server_registration",
|
|
32604
|
+
builder: "builder_registration"
|
|
32605
|
+
};
|
|
32606
|
+
function operationNameFor(kind, opts) {
|
|
32607
|
+
switch (kind) {
|
|
32608
|
+
case "grant_registration":
|
|
32609
|
+
return opts?.grantRegistrationOpName ?? "grant_registration";
|
|
32610
|
+
case "data_access":
|
|
32611
|
+
return opts?.dataAccessOpName ?? "data_access";
|
|
32612
|
+
case "data_registration":
|
|
32613
|
+
return opts?.dataRegistrationOpName ?? "data_registration";
|
|
32614
|
+
case "server_registration":
|
|
32615
|
+
return opts?.serverRegistrationOpName ?? "server_registration";
|
|
32616
|
+
case "builder_registration":
|
|
32617
|
+
return opts?.builderRegistrationOpName ?? "builder_registration";
|
|
32618
|
+
}
|
|
32619
|
+
}
|
|
32620
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
32621
|
+
async function getFee(client, config, kind, opts) {
|
|
32622
|
+
const address = config.contracts.feeRegistry;
|
|
32623
|
+
const opName = operationNameFor(kind, opts);
|
|
32624
|
+
const opKey = await client.readContract({
|
|
32625
|
+
address,
|
|
32626
|
+
abi: FEE_REGISTRY_ABI,
|
|
32627
|
+
functionName: "operationKey",
|
|
32628
|
+
args: [opName]
|
|
32629
|
+
});
|
|
32630
|
+
const fee = await client.readContract({
|
|
32631
|
+
address,
|
|
32632
|
+
abi: FEE_REGISTRY_ABI,
|
|
32633
|
+
functionName: "fees",
|
|
32634
|
+
args: [opKey]
|
|
32635
|
+
});
|
|
32636
|
+
if (fee.enabled && fee.payee === ZERO_ADDRESS) {
|
|
32637
|
+
throw new Error(
|
|
32638
|
+
`FeeRegistry: enabled operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
|
|
32639
|
+
);
|
|
32640
|
+
}
|
|
32641
|
+
return fee;
|
|
32642
|
+
}
|
|
32643
|
+
async function getOpFee(client, config, opType, opts) {
|
|
32644
|
+
const registrationKind = REGISTRATION_KIND_FOR_OP[opType];
|
|
32645
|
+
if (!registrationKind) {
|
|
32646
|
+
throw new Error(
|
|
32647
|
+
`getOpFee: unknown opType "${opType}" \u2014 supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(", ")}`
|
|
32648
|
+
);
|
|
32649
|
+
}
|
|
32650
|
+
const includeDataAccess = opType === "grant";
|
|
32651
|
+
const [registration, dataAccess] = await Promise.all([
|
|
32652
|
+
getFee(client, config, registrationKind, opts),
|
|
32653
|
+
includeDataAccess ? getFee(client, config, "data_access", opts) : Promise.resolve({
|
|
32654
|
+
amount: 0n,
|
|
32655
|
+
asset: ZERO_ADDRESS,
|
|
32656
|
+
payee: ZERO_ADDRESS,
|
|
32657
|
+
enabled: false
|
|
32658
|
+
})
|
|
32659
|
+
]);
|
|
32660
|
+
if (registration.enabled && dataAccess.enabled && registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
|
|
32661
|
+
throw new Error(
|
|
32662
|
+
`FeeRegistry asset mismatch for "${opType}": registration=${registration.asset} vs data_access=${dataAccess.asset}. The gateway requires both kinds to settle in the same asset when both are enabled.`
|
|
32663
|
+
);
|
|
32664
|
+
}
|
|
32665
|
+
const asset = registration.enabled ? registration.asset : dataAccess.enabled ? dataAccess.asset : ZERO_ADDRESS;
|
|
32666
|
+
return {
|
|
32667
|
+
asset,
|
|
32668
|
+
registrationFee: registration.enabled ? registration.amount : 0n,
|
|
32669
|
+
dataAccessFee: dataAccess.enabled ? dataAccess.amount : 0n,
|
|
32670
|
+
registrationEnabled: registration.enabled,
|
|
32671
|
+
dataAccessEnabled: dataAccess.enabled,
|
|
32672
|
+
registrationPayee: registration.enabled ? registration.payee : ZERO_ADDRESS,
|
|
32673
|
+
dataAccessPayee: dataAccess.enabled ? dataAccess.payee : ZERO_ADDRESS
|
|
32510
32674
|
};
|
|
32511
32675
|
}
|
|
32512
32676
|
|
|
@@ -32587,16 +32751,6 @@ function createGatewayClient(baseUrl) {
|
|
|
32587
32751
|
const envelope = await res.json();
|
|
32588
32752
|
return envelope.data;
|
|
32589
32753
|
}
|
|
32590
|
-
function normalizeFileRecord(record) {
|
|
32591
|
-
return {
|
|
32592
|
-
fileId: record.fileId ?? record.id ?? "",
|
|
32593
|
-
owner: record.owner ?? record.ownerAddress ?? "",
|
|
32594
|
-
url: record.url,
|
|
32595
|
-
schemaId: record.schemaId,
|
|
32596
|
-
createdAt: record.createdAt ?? record.addedAt ?? "",
|
|
32597
|
-
deletedAt: record.deletedAt ?? null
|
|
32598
|
-
};
|
|
32599
|
-
}
|
|
32600
32754
|
function getMutationId(body, key) {
|
|
32601
32755
|
const value = body[key] ?? body["id"];
|
|
32602
32756
|
return typeof value === "string" ? value : void 0;
|
|
@@ -32646,30 +32800,34 @@ function createGatewayClient(baseUrl) {
|
|
|
32646
32800
|
}
|
|
32647
32801
|
return unwrapEnvelope(res);
|
|
32648
32802
|
},
|
|
32649
|
-
async
|
|
32650
|
-
const res = await fetch(`${base}/v1/
|
|
32803
|
+
async getDataPoint(dataPointId) {
|
|
32804
|
+
const res = await fetch(`${base}/v1/data/${dataPointId}`);
|
|
32651
32805
|
if (res.status === 404) return null;
|
|
32652
32806
|
if (!res.ok) {
|
|
32653
32807
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32654
32808
|
}
|
|
32655
|
-
return
|
|
32809
|
+
return unwrapEnvelope(res);
|
|
32656
32810
|
},
|
|
32657
|
-
async
|
|
32811
|
+
async listDataPointsByOwner(owner, cursor, options) {
|
|
32658
32812
|
const params = new URLSearchParams({ user: owner });
|
|
32659
32813
|
if (cursor !== null) {
|
|
32660
|
-
params.set("
|
|
32814
|
+
params.set("cursor", cursor);
|
|
32815
|
+
}
|
|
32816
|
+
if (options?.since) {
|
|
32817
|
+
params.set("since", options.since);
|
|
32661
32818
|
}
|
|
32662
|
-
if (options?.
|
|
32663
|
-
params.set("
|
|
32819
|
+
if (options?.limit !== void 0) {
|
|
32820
|
+
params.set("limit", String(options.limit));
|
|
32664
32821
|
}
|
|
32665
|
-
const res = await fetch(`${base}/v1/
|
|
32822
|
+
const res = await fetch(`${base}/v1/data?${params.toString()}`);
|
|
32666
32823
|
if (!res.ok) {
|
|
32667
32824
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32668
32825
|
}
|
|
32669
|
-
const
|
|
32826
|
+
const envelope = await res.json();
|
|
32827
|
+
const nextCursor = envelope.pagination?.hasMore === false ? null : envelope.pagination?.nextCursor ?? null;
|
|
32670
32828
|
return {
|
|
32671
|
-
|
|
32672
|
-
cursor:
|
|
32829
|
+
dataPoints: envelope.data.dataPoints,
|
|
32830
|
+
cursor: nextCursor
|
|
32673
32831
|
};
|
|
32674
32832
|
},
|
|
32675
32833
|
async getSchema(schemaId) {
|
|
@@ -32710,8 +32868,8 @@ function createGatewayClient(baseUrl) {
|
|
|
32710
32868
|
alreadyRegistered: false
|
|
32711
32869
|
};
|
|
32712
32870
|
},
|
|
32713
|
-
async
|
|
32714
|
-
const res = await fetch(`${base}/v1/
|
|
32871
|
+
async registerBuilder(params) {
|
|
32872
|
+
const res = await fetch(`${base}/v1/builders`, {
|
|
32715
32873
|
method: "POST",
|
|
32716
32874
|
headers: {
|
|
32717
32875
|
"Content-Type": "application/json",
|
|
@@ -32719,22 +32877,57 @@ function createGatewayClient(baseUrl) {
|
|
|
32719
32877
|
},
|
|
32720
32878
|
body: JSON.stringify({
|
|
32721
32879
|
ownerAddress: params.ownerAddress,
|
|
32722
|
-
|
|
32723
|
-
|
|
32880
|
+
granteeAddress: params.granteeAddress,
|
|
32881
|
+
publicKey: params.publicKey,
|
|
32882
|
+
appUrl: params.appUrl
|
|
32724
32883
|
})
|
|
32725
32884
|
});
|
|
32726
32885
|
if (res.status === 409) {
|
|
32727
32886
|
const body2 = await res.json().catch(() => ({}));
|
|
32728
32887
|
return {
|
|
32729
|
-
|
|
32888
|
+
builderId: getMutationId(
|
|
32889
|
+
body2,
|
|
32890
|
+
"builderId"
|
|
32891
|
+
),
|
|
32892
|
+
alreadyRegistered: true
|
|
32730
32893
|
};
|
|
32731
32894
|
}
|
|
32732
32895
|
if (!res.ok) {
|
|
32733
32896
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32734
32897
|
}
|
|
32735
|
-
const body = await res.json();
|
|
32898
|
+
const body = await res.json().catch(() => ({}));
|
|
32736
32899
|
return {
|
|
32737
|
-
|
|
32900
|
+
builderId: getMutationId(body, "builderId"),
|
|
32901
|
+
alreadyRegistered: false
|
|
32902
|
+
};
|
|
32903
|
+
},
|
|
32904
|
+
async registerDataPoint(params) {
|
|
32905
|
+
const res = await fetch(`${base}/v1/data`, {
|
|
32906
|
+
method: "POST",
|
|
32907
|
+
headers: {
|
|
32908
|
+
"Content-Type": "application/json",
|
|
32909
|
+
Authorization: `Web3Signed ${params.signature}`
|
|
32910
|
+
},
|
|
32911
|
+
body: JSON.stringify({
|
|
32912
|
+
ownerAddress: params.ownerAddress,
|
|
32913
|
+
scope: params.scope,
|
|
32914
|
+
dataHash: params.dataHash,
|
|
32915
|
+
metadataHash: params.metadataHash,
|
|
32916
|
+
expectedVersion: params.expectedVersion
|
|
32917
|
+
})
|
|
32918
|
+
});
|
|
32919
|
+
if (!res.ok) {
|
|
32920
|
+
const body2 = await res.json().catch(() => ({}));
|
|
32921
|
+
const detail = body2.error ?? res.statusText;
|
|
32922
|
+
throw new Error(`Gateway error: ${res.status} ${detail}`);
|
|
32923
|
+
}
|
|
32924
|
+
const body = await res.json().catch(() => ({}));
|
|
32925
|
+
return {
|
|
32926
|
+
dataPointId: getMutationId(
|
|
32927
|
+
body,
|
|
32928
|
+
"dataPointId"
|
|
32929
|
+
),
|
|
32930
|
+
expectedVersion: body.expectedVersion
|
|
32738
32931
|
};
|
|
32739
32932
|
},
|
|
32740
32933
|
async createGrant(params) {
|
|
@@ -32747,8 +32940,9 @@ function createGatewayClient(baseUrl) {
|
|
|
32747
32940
|
body: JSON.stringify({
|
|
32748
32941
|
grantorAddress: params.grantorAddress,
|
|
32749
32942
|
granteeId: params.granteeId,
|
|
32750
|
-
|
|
32751
|
-
|
|
32943
|
+
scopes: params.scopes,
|
|
32944
|
+
grantVersion: params.grantVersion,
|
|
32945
|
+
expiresAt: params.expiresAt
|
|
32752
32946
|
})
|
|
32753
32947
|
});
|
|
32754
32948
|
if (res.status === 409) {
|
|
@@ -32773,7 +32967,8 @@ function createGatewayClient(baseUrl) {
|
|
|
32773
32967
|
Authorization: `Web3Signed ${params.signature}`
|
|
32774
32968
|
},
|
|
32775
32969
|
body: JSON.stringify({
|
|
32776
|
-
grantorAddress: params.grantorAddress
|
|
32970
|
+
grantorAddress: params.grantorAddress,
|
|
32971
|
+
grantVersion: params.grantVersion
|
|
32777
32972
|
})
|
|
32778
32973
|
});
|
|
32779
32974
|
if (res.status === 409) return;
|
|
@@ -32781,21 +32976,62 @@ function createGatewayClient(baseUrl) {
|
|
|
32781
32976
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32782
32977
|
}
|
|
32783
32978
|
},
|
|
32784
|
-
async
|
|
32785
|
-
const res = await fetch(`${base}/v1/
|
|
32786
|
-
|
|
32979
|
+
async getEscrowBalance(account) {
|
|
32980
|
+
const res = await fetch(`${base}/v1/escrow/balance?account=${account}`);
|
|
32981
|
+
if (!res.ok) {
|
|
32982
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32983
|
+
}
|
|
32984
|
+
return await res.json();
|
|
32985
|
+
},
|
|
32986
|
+
async submitEscrowDeposit(params) {
|
|
32987
|
+
const res = await fetch(`${base}/v1/escrow/deposit`, {
|
|
32988
|
+
method: "POST",
|
|
32989
|
+
headers: { "Content-Type": "application/json" },
|
|
32990
|
+
body: JSON.stringify({ txHash: params.txHash })
|
|
32991
|
+
});
|
|
32992
|
+
if (res.status !== 200 && res.status !== 202) {
|
|
32993
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32994
|
+
}
|
|
32995
|
+
return await res.json();
|
|
32996
|
+
},
|
|
32997
|
+
async payForOperation(params) {
|
|
32998
|
+
const body = {
|
|
32999
|
+
payerAddress: params.payerAddress,
|
|
33000
|
+
opType: params.opType,
|
|
33001
|
+
opId: params.opId,
|
|
33002
|
+
asset: params.asset,
|
|
33003
|
+
amount: params.amount,
|
|
33004
|
+
paymentNonce: params.paymentNonce
|
|
33005
|
+
};
|
|
33006
|
+
if (params.accessRecord) {
|
|
33007
|
+
body["accessRecord"] = params.accessRecord;
|
|
33008
|
+
}
|
|
33009
|
+
const res = await fetch(`${base}/v1/escrow/pay`, {
|
|
33010
|
+
method: "POST",
|
|
32787
33011
|
headers: {
|
|
32788
33012
|
"Content-Type": "application/json",
|
|
32789
33013
|
Authorization: `Web3Signed ${params.signature}`
|
|
32790
33014
|
},
|
|
32791
|
-
body: JSON.stringify(
|
|
32792
|
-
|
|
32793
|
-
|
|
33015
|
+
body: JSON.stringify(body)
|
|
33016
|
+
});
|
|
33017
|
+
if (!res.ok) {
|
|
33018
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33019
|
+
}
|
|
33020
|
+
return await res.json();
|
|
33021
|
+
},
|
|
33022
|
+
async settle(params) {
|
|
33023
|
+
const res = await fetch(`${base}/v1/settle`, {
|
|
33024
|
+
method: "POST",
|
|
33025
|
+
headers: { "Content-Type": "application/json" },
|
|
33026
|
+
// The gateway accepts an empty body; only `limit` is recognised.
|
|
33027
|
+
// Always send a JSON body so the gateway's req.body shape parse
|
|
33028
|
+
// doesn't have to deal with an undefined.
|
|
33029
|
+
body: JSON.stringify(params ?? {})
|
|
32794
33030
|
});
|
|
32795
|
-
if (res.status === 409) return;
|
|
32796
33031
|
if (!res.ok) {
|
|
32797
33032
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32798
33033
|
}
|
|
33034
|
+
return await res.json();
|
|
32799
33035
|
}
|
|
32800
33036
|
};
|
|
32801
33037
|
}
|
|
@@ -32864,6 +33100,7 @@ async function parsePSError(response) {
|
|
|
32864
33100
|
}
|
|
32865
33101
|
export {
|
|
32866
33102
|
ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
|
|
33103
|
+
ADD_DATA_TYPES,
|
|
32867
33104
|
AccountPersonalServerLiteOwnerBindingError,
|
|
32868
33105
|
AccountPersonalServerRegistrationError,
|
|
32869
33106
|
BUILDER_REGISTRATION_TYPES,
|
|
@@ -32874,12 +33111,15 @@ export {
|
|
|
32874
33111
|
CallbackStorage,
|
|
32875
33112
|
ContractFactory,
|
|
32876
33113
|
ContractNotFoundError,
|
|
33114
|
+
DATA_REGISTRY_STATUS_ABI,
|
|
32877
33115
|
DataFileEnvelopeSchema,
|
|
33116
|
+
DataPointStatus,
|
|
32878
33117
|
DropboxStorage,
|
|
32879
33118
|
ECIESError,
|
|
33119
|
+
ESCROW_DEPOSIT_ABI,
|
|
32880
33120
|
ExpiredTokenError,
|
|
32881
|
-
|
|
32882
|
-
|
|
33121
|
+
FEE_REGISTRY_ABI,
|
|
33122
|
+
GENERIC_PAYMENT_TYPES,
|
|
32883
33123
|
GRANT_REGISTRATION_TYPES,
|
|
32884
33124
|
GRANT_REVOCATION_TYPES,
|
|
32885
33125
|
GoogleDriveStorage,
|
|
@@ -32890,6 +33130,7 @@ export {
|
|
|
32890
33130
|
IpfsStorage,
|
|
32891
33131
|
MASTER_KEY_MESSAGE,
|
|
32892
33132
|
MissingAuthError,
|
|
33133
|
+
NATIVE_VANA_ASSET,
|
|
32893
33134
|
NetworkError,
|
|
32894
33135
|
NonceError,
|
|
32895
33136
|
OAuthClient,
|
|
@@ -32905,6 +33146,8 @@ export {
|
|
|
32905
33146
|
PersonalServerError,
|
|
32906
33147
|
PinataStorage,
|
|
32907
33148
|
R2Storage,
|
|
33149
|
+
RECORD_DATA_ACCESS_TYPES,
|
|
33150
|
+
REGISTRATION_KIND_FOR_OP,
|
|
32908
33151
|
ReadOnlyError,
|
|
32909
33152
|
RelayerError,
|
|
32910
33153
|
SERVER_REGISTRATION_TYPES,
|
|
@@ -32919,10 +33162,14 @@ export {
|
|
|
32919
33162
|
VanaError,
|
|
32920
33163
|
VanaStorage,
|
|
32921
33164
|
assertValidPkceVerifier,
|
|
33165
|
+
buildDepositNativeRequest,
|
|
33166
|
+
buildDepositTokenRequest,
|
|
33167
|
+
buildMarkDataPointUnavailableRequest,
|
|
32922
33168
|
buildPersonalServerLiteOwnerBindingMessage,
|
|
32923
33169
|
buildPersonalServerLiteOwnerBindingSignature,
|
|
32924
33170
|
buildPersonalServerRegistrationSignature,
|
|
32925
33171
|
buildPersonalServerRegistrationTypedData,
|
|
33172
|
+
buildSetDataPointStatusRequest,
|
|
32926
33173
|
buildWeb3SignedHeader,
|
|
32927
33174
|
builderRegistrationDomain,
|
|
32928
33175
|
chains,
|
|
@@ -32937,14 +33184,19 @@ export {
|
|
|
32937
33184
|
createVanaStorageProvider,
|
|
32938
33185
|
createViemPersonalServerLiteOwnerBindingSigner,
|
|
32939
33186
|
createViemPersonalServerRegistrationSigner,
|
|
33187
|
+
dataRegistryContractAddress,
|
|
33188
|
+
dataRegistryDomain,
|
|
32940
33189
|
decryptWithPassword,
|
|
32941
33190
|
deriveMasterKey,
|
|
32942
33191
|
deriveScopeKey,
|
|
32943
33192
|
deserializeECIES,
|
|
32944
33193
|
detectPlatform,
|
|
33194
|
+
encodeDepositNativeData,
|
|
33195
|
+
encodeDepositTokenData,
|
|
33196
|
+
encodeSetDataPointStatusData,
|
|
32945
33197
|
encryptWithPassword,
|
|
32946
|
-
|
|
32947
|
-
|
|
33198
|
+
escrowContractAddress,
|
|
33199
|
+
escrowPaymentDomain,
|
|
32948
33200
|
generatePkceVerifier,
|
|
32949
33201
|
getAbi,
|
|
32950
33202
|
getAllChains,
|
|
@@ -32952,6 +33204,8 @@ export {
|
|
|
32952
33204
|
getContractAddress,
|
|
32953
33205
|
getContractController,
|
|
32954
33206
|
getContractInfo,
|
|
33207
|
+
getFee,
|
|
33208
|
+
getOpFee,
|
|
32955
33209
|
getPlatformCapabilities,
|
|
32956
33210
|
getServiceEndpoints,
|
|
32957
33211
|
grantRegistrationDomain,
|
|
@@ -32963,7 +33217,6 @@ export {
|
|
|
32963
33217
|
moksha,
|
|
32964
33218
|
mokshaServices,
|
|
32965
33219
|
mokshaTestnet2 as mokshaTestnet,
|
|
32966
|
-
parseGrantRegistrationPayload,
|
|
32967
33220
|
parsePSError,
|
|
32968
33221
|
parseScope,
|
|
32969
33222
|
parseWeb3SignedHeader,
|