@opendatalabs/vana-sdk 3.5.0 → 3.5.1-pr.159.2d90789
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/README.md +116 -0
- package/dist/direct/access-request-client.cjs +104 -0
- package/dist/direct/access-request-client.cjs.map +1 -0
- package/dist/direct/access-request-client.d.ts +51 -0
- package/dist/direct/access-request-client.js +79 -0
- package/dist/direct/access-request-client.js.map +1 -0
- package/dist/direct/access-request-client.test.d.ts +1 -0
- package/dist/direct/connect-flow.cjs +152 -0
- package/dist/direct/connect-flow.cjs.map +1 -0
- package/dist/direct/connect-flow.d.ts +85 -0
- package/dist/direct/connect-flow.js +128 -0
- package/dist/direct/connect-flow.js.map +1 -0
- package/dist/direct/connect-flow.test.d.ts +1 -0
- package/dist/direct/controller.cjs +129 -0
- package/dist/direct/controller.cjs.map +1 -0
- package/dist/direct/controller.d.ts +152 -0
- package/dist/direct/controller.js +109 -0
- package/dist/direct/controller.js.map +1 -0
- package/dist/direct/controller.test.d.ts +1 -0
- package/dist/direct/endpoints.cjs +45 -0
- package/dist/direct/endpoints.cjs.map +1 -0
- package/dist/direct/endpoints.d.ts +22 -0
- package/dist/direct/endpoints.js +19 -0
- package/dist/direct/endpoints.js.map +1 -0
- package/dist/direct/errors.cjs +65 -0
- package/dist/direct/errors.cjs.map +1 -0
- package/dist/direct/errors.d.ts +44 -0
- package/dist/direct/errors.js +38 -0
- package/dist/direct/errors.js.map +1 -0
- package/dist/direct/escrow-payment.cjs +96 -0
- package/dist/direct/escrow-payment.cjs.map +1 -0
- package/dist/direct/escrow-payment.d.ts +81 -0
- package/dist/direct/escrow-payment.js +72 -0
- package/dist/direct/escrow-payment.js.map +1 -0
- package/dist/direct/escrow-payment.test.d.ts +1 -0
- package/dist/direct/personal-server-read.cjs +149 -0
- package/dist/direct/personal-server-read.cjs.map +1 -0
- package/dist/direct/personal-server-read.d.ts +103 -0
- package/dist/direct/personal-server-read.js +124 -0
- package/dist/direct/personal-server-read.js.map +1 -0
- package/dist/direct/personal-server-read.test.d.ts +1 -0
- package/dist/direct/types.cjs +35 -0
- package/dist/direct/types.cjs.map +1 -0
- package/dist/direct/types.d.ts +205 -0
- package/dist/direct/types.js +11 -0
- package/dist/direct/types.js.map +1 -0
- package/dist/direct/use-direct-vana-connect.cjs +68 -0
- package/dist/direct/use-direct-vana-connect.cjs.map +1 -0
- package/dist/direct/use-direct-vana-connect.d.ts +45 -0
- package/dist/direct/use-direct-vana-connect.js +46 -0
- package/dist/direct/use-direct-vana-connect.js.map +1 -0
- package/dist/index.browser.d.ts +7 -3
- package/dist/index.browser.js +513 -174
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +536 -179
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +7 -3
- package/dist/index.node.js +513 -174
- 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 +107 -37
- package/dist/protocol/gateway.cjs.map +1 -1
- package/dist/protocol/gateway.d.ts +223 -57
- package/dist/protocol/gateway.js +107 -37
- 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/dist/protocol/personal-server-data.cjs +71 -0
- package/dist/protocol/personal-server-data.cjs.map +1 -0
- package/dist/protocol/personal-server-data.d.ts +16 -0
- package/dist/protocol/personal-server-data.js +47 -0
- package/dist/protocol/personal-server-data.js.map +1 -0
- package/dist/protocol/personal-server-data.test.d.ts +1 -0
- package/dist/protocol/personal-server-lite-owner-binding.cjs +93 -0
- package/dist/protocol/personal-server-lite-owner-binding.cjs.map +1 -0
- package/dist/protocol/personal-server-lite-owner-binding.d.ts +44 -0
- package/dist/protocol/personal-server-lite-owner-binding.js +65 -0
- package/dist/protocol/personal-server-lite-owner-binding.js.map +1 -0
- package/dist/protocol/personal-server-lite-owner-binding.test.d.ts +1 -0
- package/dist/react.cjs +32 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.ts +33 -0
- package/dist/react.js +11 -0
- package/dist/react.js.map +1 -0
- package/dist/server.cjs +73 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.ts +32 -0
- package/dist/server.js +55 -0
- package/dist/server.js.map +1 -0
- package/dist/storage/providers/vana-storage.cjs +75 -17
- package/dist/storage/providers/vana-storage.cjs.map +1 -1
- package/dist/storage/providers/vana-storage.js +75 -17
- package/dist/storage/providers/vana-storage.js.map +1 -1
- package/package.json +20 -1
package/dist/index.browser.js
CHANGED
|
@@ -29009,6 +29009,8 @@ async function buildWeb3SignedHeader(params) {
|
|
|
29009
29009
|
var DEFAULT_ENDPOINT = "https://storage.vana.org";
|
|
29010
29010
|
var BLOB_PATH_PREFIX = "/v1/blobs";
|
|
29011
29011
|
var DEFAULT_TOKEN_TTL_SECONDS = 300;
|
|
29012
|
+
var MAX_UPLOAD_ATTEMPTS = 4;
|
|
29013
|
+
var MAX_RATE_LIMIT_DELAY_MS = 3e4;
|
|
29012
29014
|
var VanaStorage = class {
|
|
29013
29015
|
endpoint;
|
|
29014
29016
|
signer;
|
|
@@ -29047,27 +29049,46 @@ var VanaStorage = class {
|
|
|
29047
29049
|
const body = new Uint8Array(await file.arrayBuffer());
|
|
29048
29050
|
const contentType = file.type !== "" ? file.type : "application/octet-stream";
|
|
29049
29051
|
const header = await this.signRequest("PUT", path, body);
|
|
29050
|
-
let response;
|
|
29051
|
-
|
|
29052
|
-
|
|
29053
|
-
|
|
29054
|
-
|
|
29055
|
-
|
|
29056
|
-
|
|
29057
|
-
|
|
29058
|
-
|
|
29059
|
-
|
|
29060
|
-
|
|
29052
|
+
let response = null;
|
|
29053
|
+
let responseText = "";
|
|
29054
|
+
for (let attempt = 1; attempt <= MAX_UPLOAD_ATTEMPTS; attempt++) {
|
|
29055
|
+
try {
|
|
29056
|
+
response = await this.fetchImpl(`${this.endpoint}${path}`, {
|
|
29057
|
+
method: "PUT",
|
|
29058
|
+
headers: {
|
|
29059
|
+
authorization: header,
|
|
29060
|
+
"content-type": contentType
|
|
29061
|
+
},
|
|
29062
|
+
body
|
|
29063
|
+
});
|
|
29064
|
+
} catch (cause) {
|
|
29065
|
+
throw new StorageError(
|
|
29066
|
+
`vana-storage upload network error: ${describe(cause)}`,
|
|
29067
|
+
"UPLOAD_ERROR",
|
|
29068
|
+
"vana-storage",
|
|
29069
|
+
{ cause: cause instanceof Error ? cause : void 0 }
|
|
29070
|
+
);
|
|
29071
|
+
}
|
|
29072
|
+
if (response.ok) {
|
|
29073
|
+
break;
|
|
29074
|
+
}
|
|
29075
|
+
responseText = await safeText(response);
|
|
29076
|
+
if (response.status === 429 && attempt < MAX_UPLOAD_ATTEMPTS) {
|
|
29077
|
+
const delayMs = retryDelayMs(response, responseText);
|
|
29078
|
+
if (delayMs > 0) {
|
|
29079
|
+
await sleep(delayMs);
|
|
29080
|
+
}
|
|
29081
|
+
continue;
|
|
29082
|
+
}
|
|
29061
29083
|
throw new StorageError(
|
|
29062
|
-
`vana-storage upload
|
|
29063
|
-
"
|
|
29064
|
-
"vana-storage"
|
|
29065
|
-
{ cause: cause instanceof Error ? cause : void 0 }
|
|
29084
|
+
`vana-storage upload failed: ${response.status} ${response.statusText} - ${responseText}`,
|
|
29085
|
+
"UPLOAD_FAILED",
|
|
29086
|
+
"vana-storage"
|
|
29066
29087
|
);
|
|
29067
29088
|
}
|
|
29068
|
-
if (!response
|
|
29089
|
+
if (!response?.ok) {
|
|
29069
29090
|
throw new StorageError(
|
|
29070
|
-
`vana-storage upload failed
|
|
29091
|
+
`vana-storage upload failed after ${MAX_UPLOAD_ATTEMPTS} attempts - ${responseText}`,
|
|
29071
29092
|
"UPLOAD_FAILED",
|
|
29072
29093
|
"vana-storage"
|
|
29073
29094
|
);
|
|
@@ -29220,6 +29241,43 @@ function describe(value) {
|
|
|
29220
29241
|
if (value instanceof Error) return value.message;
|
|
29221
29242
|
return String(value);
|
|
29222
29243
|
}
|
|
29244
|
+
function retryDelayMs(response, responseText) {
|
|
29245
|
+
const headerDelayMs = parseRetryAfterHeaderMs(
|
|
29246
|
+
response.headers.get("retry-after")
|
|
29247
|
+
);
|
|
29248
|
+
if (headerDelayMs !== null) {
|
|
29249
|
+
return clampRateLimitDelay(headerDelayMs);
|
|
29250
|
+
}
|
|
29251
|
+
return clampRateLimitDelay(parseRetryAfterBodyMs(responseText) ?? 0);
|
|
29252
|
+
}
|
|
29253
|
+
function parseRetryAfterHeaderMs(value) {
|
|
29254
|
+
if (!value) return null;
|
|
29255
|
+
const seconds = Number(value);
|
|
29256
|
+
if (Number.isFinite(seconds)) {
|
|
29257
|
+
return seconds * 1e3;
|
|
29258
|
+
}
|
|
29259
|
+
const dateMs = Date.parse(value);
|
|
29260
|
+
if (Number.isFinite(dateMs)) {
|
|
29261
|
+
return Math.max(0, dateMs - Date.now());
|
|
29262
|
+
}
|
|
29263
|
+
return null;
|
|
29264
|
+
}
|
|
29265
|
+
function parseRetryAfterBodyMs(responseText) {
|
|
29266
|
+
if (!responseText) return null;
|
|
29267
|
+
try {
|
|
29268
|
+
const parsed = JSON.parse(responseText);
|
|
29269
|
+
const seconds = Number(parsed.retryAfter);
|
|
29270
|
+
return Number.isFinite(seconds) ? seconds * 1e3 : null;
|
|
29271
|
+
} catch {
|
|
29272
|
+
return null;
|
|
29273
|
+
}
|
|
29274
|
+
}
|
|
29275
|
+
function clampRateLimitDelay(delayMs) {
|
|
29276
|
+
return Math.min(Math.max(0, delayMs), MAX_RATE_LIMIT_DELAY_MS);
|
|
29277
|
+
}
|
|
29278
|
+
function sleep(ms) {
|
|
29279
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
29280
|
+
}
|
|
29223
29281
|
async function safeText(response) {
|
|
29224
29282
|
try {
|
|
29225
29283
|
return await response.text();
|
|
@@ -31882,6 +31940,7 @@ async function verifyWeb3Signed(params) {
|
|
|
31882
31940
|
// src/protocol/eip712.ts
|
|
31883
31941
|
var DOMAIN_NAME = "Vana Data Portability";
|
|
31884
31942
|
var DOMAIN_VERSION = "1";
|
|
31943
|
+
var NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
|
|
31885
31944
|
function buildDomain(chainId, verifyingContract) {
|
|
31886
31945
|
return {
|
|
31887
31946
|
name: DOMAIN_NAME,
|
|
@@ -31890,13 +31949,7 @@ function buildDomain(chainId, verifyingContract) {
|
|
|
31890
31949
|
verifyingContract
|
|
31891
31950
|
};
|
|
31892
31951
|
}
|
|
31893
|
-
function
|
|
31894
|
-
return buildDomain(
|
|
31895
|
-
config.chainId,
|
|
31896
|
-
config.contracts.dataRegistry
|
|
31897
|
-
);
|
|
31898
|
-
}
|
|
31899
|
-
function fileDeletionDomain(config) {
|
|
31952
|
+
function dataRegistryDomain(config) {
|
|
31900
31953
|
return buildDomain(
|
|
31901
31954
|
config.chainId,
|
|
31902
31955
|
config.contracts.dataRegistry
|
|
@@ -31926,31 +31979,26 @@ function builderRegistrationDomain(config) {
|
|
|
31926
31979
|
config.contracts.dataPortabilityGrantees
|
|
31927
31980
|
);
|
|
31928
31981
|
}
|
|
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
|
-
};
|
|
31982
|
+
function escrowPaymentDomain(config) {
|
|
31983
|
+
return buildDomain(
|
|
31984
|
+
config.chainId,
|
|
31985
|
+
config.contracts.dataPortabilityEscrow
|
|
31986
|
+
);
|
|
31987
|
+
}
|
|
31942
31988
|
var GRANT_REGISTRATION_TYPES = {
|
|
31943
31989
|
GrantRegistration: [
|
|
31944
31990
|
{ name: "grantorAddress", type: "address" },
|
|
31945
31991
|
{ name: "granteeId", type: "bytes32" },
|
|
31946
|
-
{ name: "
|
|
31947
|
-
{ name: "
|
|
31992
|
+
{ name: "scopes", type: "string[]" },
|
|
31993
|
+
{ name: "grantVersion", type: "uint256" },
|
|
31994
|
+
{ name: "expiresAt", type: "uint256" }
|
|
31948
31995
|
]
|
|
31949
31996
|
};
|
|
31950
31997
|
var GRANT_REVOCATION_TYPES = {
|
|
31951
31998
|
GrantRevocation: [
|
|
31952
31999
|
{ name: "grantorAddress", type: "address" },
|
|
31953
|
-
{ name: "grantId", type: "bytes32" }
|
|
32000
|
+
{ name: "grantId", type: "bytes32" },
|
|
32001
|
+
{ name: "grantVersion", type: "uint256" }
|
|
31954
32002
|
]
|
|
31955
32003
|
};
|
|
31956
32004
|
var SERVER_REGISTRATION_TYPES = {
|
|
@@ -31969,6 +32017,24 @@ var BUILDER_REGISTRATION_TYPES = {
|
|
|
31969
32017
|
{ name: "appUrl", type: "string" }
|
|
31970
32018
|
]
|
|
31971
32019
|
};
|
|
32020
|
+
var ADD_DATA_TYPES = {
|
|
32021
|
+
AddData: [
|
|
32022
|
+
{ name: "ownerAddress", type: "address" },
|
|
32023
|
+
{ name: "scope", type: "string" },
|
|
32024
|
+
{ name: "dataHash", type: "bytes32" },
|
|
32025
|
+
{ name: "metadataHash", type: "bytes32" },
|
|
32026
|
+
{ name: "expectedVersion", type: "uint256" }
|
|
32027
|
+
]
|
|
32028
|
+
};
|
|
32029
|
+
var RECORD_DATA_ACCESS_TYPES = {
|
|
32030
|
+
RecordDataAccess: [
|
|
32031
|
+
{ name: "ownerAddress", type: "address" },
|
|
32032
|
+
{ name: "scope", type: "string" },
|
|
32033
|
+
{ name: "version", type: "uint256" },
|
|
32034
|
+
{ name: "accessor", type: "address" },
|
|
32035
|
+
{ name: "recordId", type: "bytes32" }
|
|
32036
|
+
]
|
|
32037
|
+
};
|
|
31972
32038
|
|
|
31973
32039
|
// src/protocol/personal-server-registration.ts
|
|
31974
32040
|
import {
|
|
@@ -32420,67 +32486,34 @@ function isDataPortabilityGatewayConfig(value) {
|
|
|
32420
32486
|
return false;
|
|
32421
32487
|
}
|
|
32422
32488
|
const c = contracts;
|
|
32423
|
-
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]);
|
|
32424
|
-
}
|
|
32425
|
-
function parseGrantRegistrationPayload(grant) {
|
|
32426
|
-
let parsed;
|
|
32427
|
-
try {
|
|
32428
|
-
parsed = JSON.parse(grant);
|
|
32429
|
-
} catch {
|
|
32430
|
-
return null;
|
|
32431
|
-
}
|
|
32432
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
32433
|
-
return null;
|
|
32434
|
-
}
|
|
32435
|
-
const value = parsed;
|
|
32436
|
-
if (!Array.isArray(value["scopes"]) || value["scopes"].length === 0) {
|
|
32437
|
-
return null;
|
|
32438
|
-
}
|
|
32439
|
-
if (!value["scopes"].every((scope) => typeof scope === "string")) {
|
|
32440
|
-
return null;
|
|
32441
|
-
}
|
|
32442
|
-
if (typeof value["expiresAt"] !== "number" || !Number.isFinite(value["expiresAt"])) {
|
|
32443
|
-
return null;
|
|
32444
|
-
}
|
|
32445
|
-
if (value["user"] !== void 0 && !isHexString(value["user"])) {
|
|
32446
|
-
return null;
|
|
32447
|
-
}
|
|
32448
|
-
if (value["builder"] !== void 0 && !isHexString(value["builder"])) {
|
|
32449
|
-
return null;
|
|
32450
|
-
}
|
|
32451
|
-
if (value["nonce"] !== void 0 && (typeof value["nonce"] !== "number" || !Number.isFinite(value["nonce"]))) {
|
|
32452
|
-
return null;
|
|
32453
|
-
}
|
|
32454
|
-
return {
|
|
32455
|
-
user: value["user"],
|
|
32456
|
-
builder: value["builder"],
|
|
32457
|
-
scopes: value["scopes"],
|
|
32458
|
-
expiresAt: value["expiresAt"],
|
|
32459
|
-
nonce: value["nonce"]
|
|
32460
|
-
};
|
|
32489
|
+
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]) && isHexString(c["dataPortabilityEscrow"]) && isHexString(c["feeRegistry"]);
|
|
32461
32490
|
}
|
|
32462
|
-
function
|
|
32491
|
+
function toUint256(value) {
|
|
32463
32492
|
try {
|
|
32464
|
-
|
|
32465
|
-
|
|
32466
|
-
|
|
32467
|
-
|
|
32468
|
-
|
|
32493
|
+
if (typeof value === "number" && !Number.isSafeInteger(value)) {
|
|
32494
|
+
return null;
|
|
32495
|
+
}
|
|
32496
|
+
const big = typeof value === "bigint" ? value : BigInt(value);
|
|
32497
|
+
if (big < 0n) return null;
|
|
32498
|
+
return big;
|
|
32469
32499
|
} catch {
|
|
32470
32500
|
return null;
|
|
32471
32501
|
}
|
|
32472
32502
|
}
|
|
32473
32503
|
async function verifyGrantRegistration(input) {
|
|
32474
|
-
|
|
32475
|
-
|
|
32476
|
-
|
|
32477
|
-
|
|
32478
|
-
|
|
32479
|
-
};
|
|
32504
|
+
if (!Array.isArray(input.scopes) || input.scopes.length === 0) {
|
|
32505
|
+
return { valid: false, error: "scopes must be a non-empty array" };
|
|
32506
|
+
}
|
|
32507
|
+
if (!input.scopes.every((scope) => typeof scope === "string")) {
|
|
32508
|
+
return { valid: false, error: "scopes must contain only strings" };
|
|
32480
32509
|
}
|
|
32481
|
-
const
|
|
32482
|
-
if (
|
|
32483
|
-
return { valid: false, error: "
|
|
32510
|
+
const grantVersion = toUint256(input.grantVersion);
|
|
32511
|
+
if (grantVersion === null || grantVersion < 1n) {
|
|
32512
|
+
return { valid: false, error: "grantVersion must be a uint256 >= 1" };
|
|
32513
|
+
}
|
|
32514
|
+
const expiresAt = toUint256(input.expiresAt);
|
|
32515
|
+
if (expiresAt === null) {
|
|
32516
|
+
return { valid: false, error: "expiresAt must be a non-negative uint256" };
|
|
32484
32517
|
}
|
|
32485
32518
|
let valid;
|
|
32486
32519
|
try {
|
|
@@ -32492,8 +32525,9 @@ async function verifyGrantRegistration(input) {
|
|
|
32492
32525
|
message: {
|
|
32493
32526
|
grantorAddress: input.grantorAddress,
|
|
32494
32527
|
granteeId: input.granteeId,
|
|
32495
|
-
|
|
32496
|
-
|
|
32528
|
+
scopes: input.scopes,
|
|
32529
|
+
grantVersion,
|
|
32530
|
+
expiresAt
|
|
32497
32531
|
},
|
|
32498
32532
|
signature: input.signature
|
|
32499
32533
|
});
|
|
@@ -32504,26 +32538,269 @@ async function verifyGrantRegistration(input) {
|
|
|
32504
32538
|
return { valid: false, error: "Grant signature does not match grantor" };
|
|
32505
32539
|
}
|
|
32506
32540
|
const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
|
|
32507
|
-
if (
|
|
32541
|
+
if (expiresAt > 0n && expiresAt < BigInt(nowSeconds)) {
|
|
32508
32542
|
return { valid: false, error: "Grant has expired" };
|
|
32509
32543
|
}
|
|
32510
|
-
if (payload.user !== void 0 && payload.user.toLowerCase() !== input.grantorAddress.toLowerCase()) {
|
|
32511
|
-
return { valid: false, error: "Grant user does not match grantorAddress" };
|
|
32512
|
-
}
|
|
32513
32544
|
return {
|
|
32514
32545
|
valid: true,
|
|
32515
32546
|
grantorAddress: input.grantorAddress,
|
|
32516
32547
|
granteeId: input.granteeId,
|
|
32517
|
-
|
|
32518
|
-
|
|
32519
|
-
|
|
32548
|
+
scopes: input.scopes,
|
|
32549
|
+
grantVersion: grantVersion.toString(),
|
|
32550
|
+
expiresAt: expiresAt.toString()
|
|
32520
32551
|
};
|
|
32521
32552
|
}
|
|
32522
32553
|
|
|
32523
|
-
// src/protocol/
|
|
32554
|
+
// src/protocol/fee-registry.ts
|
|
32555
|
+
import { parseAbi } from "viem";
|
|
32556
|
+
var FEE_REGISTRY_ABI = parseAbi([
|
|
32557
|
+
"struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
|
|
32558
|
+
"function fees(bytes32 operation) view returns (Fee)",
|
|
32559
|
+
"function operationKey(string name) pure returns (bytes32)"
|
|
32560
|
+
]);
|
|
32561
|
+
var REGISTRATION_KIND_FOR_OP = {
|
|
32562
|
+
grant: "grant_registration",
|
|
32563
|
+
data: "data_registration",
|
|
32564
|
+
server: "server_registration",
|
|
32565
|
+
builder: "builder_registration"
|
|
32566
|
+
};
|
|
32567
|
+
function operationNameFor(kind, opts) {
|
|
32568
|
+
switch (kind) {
|
|
32569
|
+
case "grant_registration":
|
|
32570
|
+
return opts?.grantRegistrationOpName ?? "grant_registration";
|
|
32571
|
+
case "data_access":
|
|
32572
|
+
return opts?.dataAccessOpName ?? "data_access";
|
|
32573
|
+
case "data_registration":
|
|
32574
|
+
return opts?.dataRegistrationOpName ?? "data_registration";
|
|
32575
|
+
case "server_registration":
|
|
32576
|
+
return opts?.serverRegistrationOpName ?? "server_registration";
|
|
32577
|
+
case "builder_registration":
|
|
32578
|
+
return opts?.builderRegistrationOpName ?? "builder_registration";
|
|
32579
|
+
}
|
|
32580
|
+
}
|
|
32581
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
32582
|
+
async function getFee(client, config, kind, opts) {
|
|
32583
|
+
const address = config.contracts.feeRegistry;
|
|
32584
|
+
const opName = operationNameFor(kind, opts);
|
|
32585
|
+
const opKey = await client.readContract({
|
|
32586
|
+
address,
|
|
32587
|
+
abi: FEE_REGISTRY_ABI,
|
|
32588
|
+
functionName: "operationKey",
|
|
32589
|
+
args: [opName]
|
|
32590
|
+
});
|
|
32591
|
+
const fee = await client.readContract({
|
|
32592
|
+
address,
|
|
32593
|
+
abi: FEE_REGISTRY_ABI,
|
|
32594
|
+
functionName: "fees",
|
|
32595
|
+
args: [opKey]
|
|
32596
|
+
});
|
|
32597
|
+
if (fee.enabled && fee.payee === ZERO_ADDRESS) {
|
|
32598
|
+
throw new Error(
|
|
32599
|
+
`FeeRegistry: enabled operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
|
|
32600
|
+
);
|
|
32601
|
+
}
|
|
32602
|
+
return fee;
|
|
32603
|
+
}
|
|
32604
|
+
async function getOpFee(client, config, opType, opts) {
|
|
32605
|
+
const registrationKind = REGISTRATION_KIND_FOR_OP[opType];
|
|
32606
|
+
if (!registrationKind) {
|
|
32607
|
+
throw new Error(
|
|
32608
|
+
`getOpFee: unknown opType "${opType}" \u2014 supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(", ")}`
|
|
32609
|
+
);
|
|
32610
|
+
}
|
|
32611
|
+
const includeDataAccess = opType === "grant";
|
|
32612
|
+
const [registration, dataAccess] = await Promise.all([
|
|
32613
|
+
getFee(client, config, registrationKind, opts),
|
|
32614
|
+
includeDataAccess ? getFee(client, config, "data_access", opts) : Promise.resolve({
|
|
32615
|
+
amount: 0n,
|
|
32616
|
+
asset: ZERO_ADDRESS,
|
|
32617
|
+
payee: ZERO_ADDRESS,
|
|
32618
|
+
enabled: false
|
|
32619
|
+
})
|
|
32620
|
+
]);
|
|
32621
|
+
if (registration.enabled && dataAccess.enabled && registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
|
|
32622
|
+
throw new Error(
|
|
32623
|
+
`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.`
|
|
32624
|
+
);
|
|
32625
|
+
}
|
|
32626
|
+
const asset = registration.enabled ? registration.asset : dataAccess.enabled ? dataAccess.asset : ZERO_ADDRESS;
|
|
32627
|
+
return {
|
|
32628
|
+
asset,
|
|
32629
|
+
registrationFee: registration.enabled ? registration.amount : 0n,
|
|
32630
|
+
dataAccessFee: dataAccess.enabled ? dataAccess.amount : 0n,
|
|
32631
|
+
registrationEnabled: registration.enabled,
|
|
32632
|
+
dataAccessEnabled: dataAccess.enabled,
|
|
32633
|
+
registrationPayee: registration.enabled ? registration.payee : ZERO_ADDRESS,
|
|
32634
|
+
dataAccessPayee: dataAccess.enabled ? dataAccess.payee : ZERO_ADDRESS
|
|
32635
|
+
};
|
|
32636
|
+
}
|
|
32637
|
+
|
|
32638
|
+
// src/protocol/escrow-deposit.ts
|
|
32639
|
+
import { encodeFunctionData } from "viem";
|
|
32640
|
+
var ESCROW_DEPOSIT_ABI = [
|
|
32641
|
+
{
|
|
32642
|
+
type: "function",
|
|
32643
|
+
name: "depositNative",
|
|
32644
|
+
stateMutability: "payable",
|
|
32645
|
+
inputs: [{ name: "account", type: "address" }],
|
|
32646
|
+
outputs: []
|
|
32647
|
+
},
|
|
32648
|
+
{
|
|
32649
|
+
type: "function",
|
|
32650
|
+
name: "depositToken",
|
|
32651
|
+
stateMutability: "nonpayable",
|
|
32652
|
+
inputs: [
|
|
32653
|
+
{ name: "account", type: "address" },
|
|
32654
|
+
{ name: "token", type: "address" },
|
|
32655
|
+
{ name: "amount", type: "uint256" }
|
|
32656
|
+
],
|
|
32657
|
+
outputs: []
|
|
32658
|
+
}
|
|
32659
|
+
];
|
|
32660
|
+
function escrowContractAddress(config) {
|
|
32661
|
+
return config.contracts.dataPortabilityEscrow;
|
|
32662
|
+
}
|
|
32663
|
+
function encodeDepositNativeData(input) {
|
|
32664
|
+
return encodeFunctionData({
|
|
32665
|
+
abi: ESCROW_DEPOSIT_ABI,
|
|
32666
|
+
functionName: "depositNative",
|
|
32667
|
+
args: [input.account]
|
|
32668
|
+
});
|
|
32669
|
+
}
|
|
32670
|
+
function encodeDepositTokenData(input) {
|
|
32671
|
+
return encodeFunctionData({
|
|
32672
|
+
abi: ESCROW_DEPOSIT_ABI,
|
|
32673
|
+
functionName: "depositToken",
|
|
32674
|
+
args: [input.account, input.token, input.amount]
|
|
32675
|
+
});
|
|
32676
|
+
}
|
|
32677
|
+
function buildDepositNativeRequest(config, input) {
|
|
32678
|
+
return {
|
|
32679
|
+
to: escrowContractAddress(config),
|
|
32680
|
+
data: encodeDepositNativeData({ account: input.account }),
|
|
32681
|
+
value: input.amount
|
|
32682
|
+
};
|
|
32683
|
+
}
|
|
32684
|
+
function buildDepositTokenRequest(config, input) {
|
|
32685
|
+
return {
|
|
32686
|
+
to: escrowContractAddress(config),
|
|
32687
|
+
data: encodeDepositTokenData(input)
|
|
32688
|
+
};
|
|
32689
|
+
}
|
|
32690
|
+
|
|
32691
|
+
// src/protocol/data-point-status.ts
|
|
32692
|
+
import { encodeFunctionData as encodeFunctionData2 } from "viem";
|
|
32693
|
+
var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
|
|
32694
|
+
DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
|
|
32695
|
+
DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
|
|
32696
|
+
DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
|
|
32697
|
+
DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
|
|
32698
|
+
return DataPointStatus2;
|
|
32699
|
+
})(DataPointStatus || {});
|
|
32700
|
+
var DATA_REGISTRY_STATUS_ABI = [
|
|
32701
|
+
{
|
|
32702
|
+
type: "function",
|
|
32703
|
+
name: "setStatus",
|
|
32704
|
+
stateMutability: "nonpayable",
|
|
32705
|
+
inputs: [
|
|
32706
|
+
{ name: "scope", type: "string" },
|
|
32707
|
+
{ name: "newStatus", type: "uint8" }
|
|
32708
|
+
],
|
|
32709
|
+
outputs: []
|
|
32710
|
+
}
|
|
32711
|
+
];
|
|
32712
|
+
function dataRegistryContractAddress(config) {
|
|
32713
|
+
return config.contracts.dataRegistry;
|
|
32714
|
+
}
|
|
32715
|
+
function encodeSetDataPointStatusData(input) {
|
|
32716
|
+
return encodeFunctionData2({
|
|
32717
|
+
abi: DATA_REGISTRY_STATUS_ABI,
|
|
32718
|
+
functionName: "setStatus",
|
|
32719
|
+
args: [input.scope, input.status]
|
|
32720
|
+
});
|
|
32721
|
+
}
|
|
32722
|
+
function buildSetDataPointStatusRequest(config, input) {
|
|
32723
|
+
return {
|
|
32724
|
+
to: dataRegistryContractAddress(config),
|
|
32725
|
+
data: encodeSetDataPointStatusData(input)
|
|
32726
|
+
};
|
|
32727
|
+
}
|
|
32728
|
+
function buildMarkDataPointUnavailableRequest(config, input) {
|
|
32729
|
+
return buildSetDataPointStatusRequest(config, {
|
|
32730
|
+
scope: input.scope,
|
|
32731
|
+
status: 3 /* Unavailable */
|
|
32732
|
+
});
|
|
32733
|
+
}
|
|
32734
|
+
|
|
32735
|
+
// src/protocol/data-file.ts
|
|
32524
32736
|
import { z } from "zod";
|
|
32737
|
+
var DataFileEnvelopeSchema = z.object({
|
|
32738
|
+
$schema: z.string().url().optional(),
|
|
32739
|
+
version: z.literal("1.0"),
|
|
32740
|
+
scope: z.string(),
|
|
32741
|
+
schemaId: z.string().optional(),
|
|
32742
|
+
collectedAt: z.string().datetime(),
|
|
32743
|
+
data: z.record(z.string(), z.unknown())
|
|
32744
|
+
});
|
|
32745
|
+
function createDataFileEnvelope(scope, collectedAt, data, schemaUrl, schemaId) {
|
|
32746
|
+
return {
|
|
32747
|
+
...schemaUrl !== void 0 && { $schema: schemaUrl },
|
|
32748
|
+
...schemaId !== void 0 && { schemaId },
|
|
32749
|
+
version: "1.0",
|
|
32750
|
+
scope,
|
|
32751
|
+
collectedAt,
|
|
32752
|
+
data
|
|
32753
|
+
};
|
|
32754
|
+
}
|
|
32755
|
+
var IngestResponseSchema = z.object({
|
|
32756
|
+
scope: z.string(),
|
|
32757
|
+
collectedAt: z.string().datetime(),
|
|
32758
|
+
status: z.enum(["stored", "syncing"])
|
|
32759
|
+
});
|
|
32760
|
+
|
|
32761
|
+
// src/protocol/personal-server-data.ts
|
|
32762
|
+
function personalServerDataReadPath(scope) {
|
|
32763
|
+
return `/v1/data/${encodeURIComponent(scope)}`;
|
|
32764
|
+
}
|
|
32765
|
+
async function buildPersonalServerDataReadRequest(params) {
|
|
32766
|
+
const path = personalServerDataReadPath(params.scope);
|
|
32767
|
+
const baseUrl = params.personalServerUrl.replace(/\/+$/, "");
|
|
32768
|
+
const audience = params.audience ?? baseUrl;
|
|
32769
|
+
const headers = new Headers(params.headers);
|
|
32770
|
+
headers.set(
|
|
32771
|
+
"Authorization",
|
|
32772
|
+
await buildWeb3SignedHeader({
|
|
32773
|
+
aud: audience,
|
|
32774
|
+
grantId: params.grantId,
|
|
32775
|
+
method: "GET",
|
|
32776
|
+
signMessage: params.signMessage,
|
|
32777
|
+
uri: path
|
|
32778
|
+
})
|
|
32779
|
+
);
|
|
32780
|
+
return new Request(`${baseUrl}${path}`, {
|
|
32781
|
+
headers,
|
|
32782
|
+
method: "GET"
|
|
32783
|
+
});
|
|
32784
|
+
}
|
|
32785
|
+
async function readPersonalServerData(params) {
|
|
32786
|
+
const fetchFn = params.fetch ?? globalThis.fetch;
|
|
32787
|
+
if (fetchFn === void 0) {
|
|
32788
|
+
throw new Error("No fetch implementation available");
|
|
32789
|
+
}
|
|
32790
|
+
const request = await buildPersonalServerDataReadRequest(params);
|
|
32791
|
+
const response = await fetchFn(request);
|
|
32792
|
+
if (!response.ok) {
|
|
32793
|
+
throw new Error(
|
|
32794
|
+
`Personal Server data read failed: ${response.status} ${response.statusText}`
|
|
32795
|
+
);
|
|
32796
|
+
}
|
|
32797
|
+
return DataFileEnvelopeSchema.parse(await response.json());
|
|
32798
|
+
}
|
|
32799
|
+
|
|
32800
|
+
// src/protocol/scopes.ts
|
|
32801
|
+
import { z as z2 } from "zod";
|
|
32525
32802
|
var SEGMENT_RE = /^[a-z0-9][a-z0-9_]*$/;
|
|
32526
|
-
var ScopeSchema =
|
|
32803
|
+
var ScopeSchema = z2.string().refine(
|
|
32527
32804
|
(scope) => {
|
|
32528
32805
|
const parts = scope.split(".");
|
|
32529
32806
|
return parts.length >= 2 && parts.length <= 3 && parts.every((part) => SEGMENT_RE.test(part));
|
|
@@ -32564,32 +32841,6 @@ function scopeCoveredByGrant(requestedScope, grantedScopes) {
|
|
|
32564
32841
|
);
|
|
32565
32842
|
}
|
|
32566
32843
|
|
|
32567
|
-
// src/protocol/data-file.ts
|
|
32568
|
-
import { z as z2 } from "zod";
|
|
32569
|
-
var DataFileEnvelopeSchema = z2.object({
|
|
32570
|
-
$schema: z2.string().url().optional(),
|
|
32571
|
-
version: z2.literal("1.0"),
|
|
32572
|
-
scope: z2.string(),
|
|
32573
|
-
schemaId: z2.string().optional(),
|
|
32574
|
-
collectedAt: z2.string().datetime(),
|
|
32575
|
-
data: z2.record(z2.string(), z2.unknown())
|
|
32576
|
-
});
|
|
32577
|
-
function createDataFileEnvelope(scope, collectedAt, data, schemaUrl, schemaId) {
|
|
32578
|
-
return {
|
|
32579
|
-
...schemaUrl !== void 0 && { $schema: schemaUrl },
|
|
32580
|
-
...schemaId !== void 0 && { schemaId },
|
|
32581
|
-
version: "1.0",
|
|
32582
|
-
scope,
|
|
32583
|
-
collectedAt,
|
|
32584
|
-
data
|
|
32585
|
-
};
|
|
32586
|
-
}
|
|
32587
|
-
var IngestResponseSchema = z2.object({
|
|
32588
|
-
scope: z2.string(),
|
|
32589
|
-
collectedAt: z2.string().datetime(),
|
|
32590
|
-
status: z2.enum(["stored", "syncing"])
|
|
32591
|
-
});
|
|
32592
|
-
|
|
32593
32844
|
// src/protocol/gateway.ts
|
|
32594
32845
|
function createGatewayClient(baseUrl) {
|
|
32595
32846
|
const base = baseUrl.replace(/\/+$/, "");
|
|
@@ -32597,16 +32848,6 @@ function createGatewayClient(baseUrl) {
|
|
|
32597
32848
|
const envelope = await res.json();
|
|
32598
32849
|
return envelope.data;
|
|
32599
32850
|
}
|
|
32600
|
-
function normalizeFileRecord(record) {
|
|
32601
|
-
return {
|
|
32602
|
-
fileId: record.fileId ?? record.id ?? "",
|
|
32603
|
-
owner: record.owner ?? record.ownerAddress ?? "",
|
|
32604
|
-
url: record.url,
|
|
32605
|
-
schemaId: record.schemaId,
|
|
32606
|
-
createdAt: record.createdAt ?? record.addedAt ?? "",
|
|
32607
|
-
deletedAt: record.deletedAt ?? null
|
|
32608
|
-
};
|
|
32609
|
-
}
|
|
32610
32851
|
function getMutationId(body, key) {
|
|
32611
32852
|
const value = body[key] ?? body["id"];
|
|
32612
32853
|
return typeof value === "string" ? value : void 0;
|
|
@@ -32656,31 +32897,33 @@ function createGatewayClient(baseUrl) {
|
|
|
32656
32897
|
}
|
|
32657
32898
|
return unwrapEnvelope(res);
|
|
32658
32899
|
},
|
|
32659
|
-
async
|
|
32660
|
-
const res = await fetch(`${base}/v1/
|
|
32900
|
+
async getDataPoint(dataPointId) {
|
|
32901
|
+
const res = await fetch(`${base}/v1/data/${dataPointId}`);
|
|
32661
32902
|
if (res.status === 404) return null;
|
|
32662
32903
|
if (!res.ok) {
|
|
32663
32904
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32664
32905
|
}
|
|
32665
|
-
return
|
|
32906
|
+
return unwrapEnvelope(res);
|
|
32666
32907
|
},
|
|
32667
|
-
async
|
|
32908
|
+
async listDataPointsByOwner(owner, cursor, options) {
|
|
32668
32909
|
const params = new URLSearchParams({ user: owner });
|
|
32669
32910
|
if (cursor !== null) {
|
|
32670
32911
|
params.set("cursor", cursor);
|
|
32671
32912
|
}
|
|
32672
|
-
if (options?.
|
|
32673
|
-
params.set("
|
|
32913
|
+
if (options?.since) {
|
|
32914
|
+
params.set("since", options.since);
|
|
32915
|
+
}
|
|
32916
|
+
if (options?.limit !== void 0) {
|
|
32917
|
+
params.set("limit", String(options.limit));
|
|
32674
32918
|
}
|
|
32675
|
-
const res = await fetch(`${base}/v1/
|
|
32919
|
+
const res = await fetch(`${base}/v1/data?${params.toString()}`);
|
|
32676
32920
|
if (!res.ok) {
|
|
32677
32921
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32678
32922
|
}
|
|
32679
32923
|
const envelope = await res.json();
|
|
32680
|
-
const
|
|
32681
|
-
const nextCursor = pagination?.hasMore === false ? null : pagination?.nextCursor ?? envelope.data.cursor ?? null;
|
|
32924
|
+
const nextCursor = envelope.pagination?.hasMore === false ? null : envelope.pagination?.nextCursor ?? null;
|
|
32682
32925
|
return {
|
|
32683
|
-
|
|
32926
|
+
dataPoints: envelope.data.dataPoints,
|
|
32684
32927
|
cursor: nextCursor
|
|
32685
32928
|
};
|
|
32686
32929
|
},
|
|
@@ -32722,8 +32965,8 @@ function createGatewayClient(baseUrl) {
|
|
|
32722
32965
|
alreadyRegistered: false
|
|
32723
32966
|
};
|
|
32724
32967
|
},
|
|
32725
|
-
async
|
|
32726
|
-
const res = await fetch(`${base}/v1/
|
|
32968
|
+
async registerBuilder(params) {
|
|
32969
|
+
const res = await fetch(`${base}/v1/builders`, {
|
|
32727
32970
|
method: "POST",
|
|
32728
32971
|
headers: {
|
|
32729
32972
|
"Content-Type": "application/json",
|
|
@@ -32731,22 +32974,57 @@ function createGatewayClient(baseUrl) {
|
|
|
32731
32974
|
},
|
|
32732
32975
|
body: JSON.stringify({
|
|
32733
32976
|
ownerAddress: params.ownerAddress,
|
|
32734
|
-
|
|
32735
|
-
|
|
32977
|
+
granteeAddress: params.granteeAddress,
|
|
32978
|
+
publicKey: params.publicKey,
|
|
32979
|
+
appUrl: params.appUrl
|
|
32736
32980
|
})
|
|
32737
32981
|
});
|
|
32738
32982
|
if (res.status === 409) {
|
|
32739
32983
|
const body2 = await res.json().catch(() => ({}));
|
|
32740
32984
|
return {
|
|
32741
|
-
|
|
32985
|
+
builderId: getMutationId(
|
|
32986
|
+
body2,
|
|
32987
|
+
"builderId"
|
|
32988
|
+
),
|
|
32989
|
+
alreadyRegistered: true
|
|
32742
32990
|
};
|
|
32743
32991
|
}
|
|
32744
32992
|
if (!res.ok) {
|
|
32745
32993
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32746
32994
|
}
|
|
32747
|
-
const body = await res.json();
|
|
32995
|
+
const body = await res.json().catch(() => ({}));
|
|
32748
32996
|
return {
|
|
32749
|
-
|
|
32997
|
+
builderId: getMutationId(body, "builderId"),
|
|
32998
|
+
alreadyRegistered: false
|
|
32999
|
+
};
|
|
33000
|
+
},
|
|
33001
|
+
async registerDataPoint(params) {
|
|
33002
|
+
const res = await fetch(`${base}/v1/data`, {
|
|
33003
|
+
method: "POST",
|
|
33004
|
+
headers: {
|
|
33005
|
+
"Content-Type": "application/json",
|
|
33006
|
+
Authorization: `Web3Signed ${params.signature}`
|
|
33007
|
+
},
|
|
33008
|
+
body: JSON.stringify({
|
|
33009
|
+
ownerAddress: params.ownerAddress,
|
|
33010
|
+
scope: params.scope,
|
|
33011
|
+
dataHash: params.dataHash,
|
|
33012
|
+
metadataHash: params.metadataHash,
|
|
33013
|
+
expectedVersion: params.expectedVersion
|
|
33014
|
+
})
|
|
33015
|
+
});
|
|
33016
|
+
if (!res.ok) {
|
|
33017
|
+
const body2 = await res.json().catch(() => ({}));
|
|
33018
|
+
const detail = body2.error ?? res.statusText;
|
|
33019
|
+
throw new Error(`Gateway error: ${res.status} ${detail}`);
|
|
33020
|
+
}
|
|
33021
|
+
const body = await res.json().catch(() => ({}));
|
|
33022
|
+
return {
|
|
33023
|
+
dataPointId: getMutationId(
|
|
33024
|
+
body,
|
|
33025
|
+
"dataPointId"
|
|
33026
|
+
),
|
|
33027
|
+
expectedVersion: body.expectedVersion
|
|
32750
33028
|
};
|
|
32751
33029
|
},
|
|
32752
33030
|
async createGrant(params) {
|
|
@@ -32759,8 +33037,9 @@ function createGatewayClient(baseUrl) {
|
|
|
32759
33037
|
body: JSON.stringify({
|
|
32760
33038
|
grantorAddress: params.grantorAddress,
|
|
32761
33039
|
granteeId: params.granteeId,
|
|
32762
|
-
|
|
32763
|
-
|
|
33040
|
+
scopes: params.scopes,
|
|
33041
|
+
grantVersion: params.grantVersion,
|
|
33042
|
+
expiresAt: params.expiresAt
|
|
32764
33043
|
})
|
|
32765
33044
|
});
|
|
32766
33045
|
if (res.status === 409) {
|
|
@@ -32785,7 +33064,8 @@ function createGatewayClient(baseUrl) {
|
|
|
32785
33064
|
Authorization: `Web3Signed ${params.signature}`
|
|
32786
33065
|
},
|
|
32787
33066
|
body: JSON.stringify({
|
|
32788
|
-
grantorAddress: params.grantorAddress
|
|
33067
|
+
grantorAddress: params.grantorAddress,
|
|
33068
|
+
grantVersion: params.grantVersion
|
|
32789
33069
|
})
|
|
32790
33070
|
});
|
|
32791
33071
|
if (res.status === 409) return;
|
|
@@ -32793,21 +33073,62 @@ function createGatewayClient(baseUrl) {
|
|
|
32793
33073
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32794
33074
|
}
|
|
32795
33075
|
},
|
|
32796
|
-
async
|
|
32797
|
-
const res = await fetch(`${base}/v1/
|
|
32798
|
-
|
|
33076
|
+
async getEscrowBalance(account) {
|
|
33077
|
+
const res = await fetch(`${base}/v1/escrow/balance?account=${account}`);
|
|
33078
|
+
if (!res.ok) {
|
|
33079
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33080
|
+
}
|
|
33081
|
+
return await res.json();
|
|
33082
|
+
},
|
|
33083
|
+
async submitEscrowDeposit(params) {
|
|
33084
|
+
const res = await fetch(`${base}/v1/escrow/deposit`, {
|
|
33085
|
+
method: "POST",
|
|
33086
|
+
headers: { "Content-Type": "application/json" },
|
|
33087
|
+
body: JSON.stringify({ txHash: params.txHash })
|
|
33088
|
+
});
|
|
33089
|
+
if (res.status !== 200 && res.status !== 202) {
|
|
33090
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33091
|
+
}
|
|
33092
|
+
return await res.json();
|
|
33093
|
+
},
|
|
33094
|
+
async payForOperation(params) {
|
|
33095
|
+
const body = {
|
|
33096
|
+
payerAddress: params.payerAddress,
|
|
33097
|
+
opType: params.opType,
|
|
33098
|
+
opId: params.opId,
|
|
33099
|
+
asset: params.asset,
|
|
33100
|
+
amount: params.amount,
|
|
33101
|
+
paymentNonce: params.paymentNonce
|
|
33102
|
+
};
|
|
33103
|
+
if (params.accessRecord) {
|
|
33104
|
+
body["accessRecord"] = params.accessRecord;
|
|
33105
|
+
}
|
|
33106
|
+
const res = await fetch(`${base}/v1/escrow/pay`, {
|
|
33107
|
+
method: "POST",
|
|
32799
33108
|
headers: {
|
|
32800
33109
|
"Content-Type": "application/json",
|
|
32801
33110
|
Authorization: `Web3Signed ${params.signature}`
|
|
32802
33111
|
},
|
|
32803
|
-
body: JSON.stringify(
|
|
32804
|
-
ownerAddress: params.ownerAddress
|
|
32805
|
-
})
|
|
33112
|
+
body: JSON.stringify(body)
|
|
32806
33113
|
});
|
|
32807
|
-
if (res.status === 409) return;
|
|
32808
33114
|
if (!res.ok) {
|
|
32809
33115
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32810
33116
|
}
|
|
33117
|
+
return await res.json();
|
|
33118
|
+
},
|
|
33119
|
+
async settle(params) {
|
|
33120
|
+
const res = await fetch(`${base}/v1/settle`, {
|
|
33121
|
+
method: "POST",
|
|
33122
|
+
headers: { "Content-Type": "application/json" },
|
|
33123
|
+
// The gateway accepts an empty body; only `limit` is recognised.
|
|
33124
|
+
// Always send a JSON body so the gateway's req.body shape parse
|
|
33125
|
+
// doesn't have to deal with an undefined.
|
|
33126
|
+
body: JSON.stringify(params ?? {})
|
|
33127
|
+
});
|
|
33128
|
+
if (!res.ok) {
|
|
33129
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33130
|
+
}
|
|
33131
|
+
return await res.json();
|
|
32811
33132
|
}
|
|
32812
33133
|
};
|
|
32813
33134
|
}
|
|
@@ -32831,7 +33152,7 @@ function genericPaymentDomain(chainId, escrowContract) {
|
|
|
32831
33152
|
verifyingContract: escrowContract
|
|
32832
33153
|
};
|
|
32833
33154
|
}
|
|
32834
|
-
var
|
|
33155
|
+
var ESCROW_DEPOSIT_ABI2 = [
|
|
32835
33156
|
{
|
|
32836
33157
|
type: "function",
|
|
32837
33158
|
name: "depositNative",
|
|
@@ -32988,6 +33309,7 @@ async function parsePSError(response) {
|
|
|
32988
33309
|
}
|
|
32989
33310
|
export {
|
|
32990
33311
|
ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
|
|
33312
|
+
ADD_DATA_TYPES,
|
|
32991
33313
|
AccountPersonalServerLiteOwnerBindingError,
|
|
32992
33314
|
AccountPersonalServerRegistrationError,
|
|
32993
33315
|
BUILDER_REGISTRATION_TYPES,
|
|
@@ -32998,13 +33320,14 @@ export {
|
|
|
32998
33320
|
CallbackStorage,
|
|
32999
33321
|
ContractFactory,
|
|
33000
33322
|
ContractNotFoundError,
|
|
33323
|
+
DATA_REGISTRY_STATUS_ABI,
|
|
33001
33324
|
DataFileEnvelopeSchema,
|
|
33325
|
+
DataPointStatus,
|
|
33002
33326
|
DropboxStorage,
|
|
33003
33327
|
ECIESError,
|
|
33004
|
-
ESCROW_DEPOSIT_ABI,
|
|
33328
|
+
ESCROW_DEPOSIT_ABI2 as ESCROW_DEPOSIT_ABI,
|
|
33005
33329
|
ExpiredTokenError,
|
|
33006
|
-
|
|
33007
|
-
FILE_REGISTRATION_TYPES,
|
|
33330
|
+
FEE_REGISTRY_ABI,
|
|
33008
33331
|
GENERIC_PAYMENT_TYPES,
|
|
33009
33332
|
GRANT_REGISTRATION_TYPES,
|
|
33010
33333
|
GRANT_REVOCATION_TYPES,
|
|
@@ -33017,6 +33340,7 @@ export {
|
|
|
33017
33340
|
MASTER_KEY_MESSAGE,
|
|
33018
33341
|
MissingAuthError,
|
|
33019
33342
|
NATIVE_ASSET_ADDRESS,
|
|
33343
|
+
NATIVE_VANA_ASSET,
|
|
33020
33344
|
NetworkError,
|
|
33021
33345
|
NonceError,
|
|
33022
33346
|
OAuthClient,
|
|
@@ -33032,6 +33356,8 @@ export {
|
|
|
33032
33356
|
PersonalServerError,
|
|
33033
33357
|
PinataStorage,
|
|
33034
33358
|
R2Storage,
|
|
33359
|
+
RECORD_DATA_ACCESS_TYPES,
|
|
33360
|
+
REGISTRATION_KIND_FOR_OP,
|
|
33035
33361
|
ReadOnlyError,
|
|
33036
33362
|
RelayerError,
|
|
33037
33363
|
SERVER_REGISTRATION_TYPES,
|
|
@@ -33046,10 +33372,15 @@ export {
|
|
|
33046
33372
|
VanaError,
|
|
33047
33373
|
VanaStorage,
|
|
33048
33374
|
assertValidPkceVerifier,
|
|
33375
|
+
buildDepositNativeRequest,
|
|
33376
|
+
buildDepositTokenRequest,
|
|
33377
|
+
buildMarkDataPointUnavailableRequest,
|
|
33378
|
+
buildPersonalServerDataReadRequest,
|
|
33049
33379
|
buildPersonalServerLiteOwnerBindingMessage,
|
|
33050
33380
|
buildPersonalServerLiteOwnerBindingSignature,
|
|
33051
33381
|
buildPersonalServerRegistrationSignature,
|
|
33052
33382
|
buildPersonalServerRegistrationTypedData,
|
|
33383
|
+
buildSetDataPointStatusRequest,
|
|
33053
33384
|
buildWeb3SignedHeader,
|
|
33054
33385
|
builderRegistrationDomain,
|
|
33055
33386
|
chains,
|
|
@@ -33065,14 +33396,19 @@ export {
|
|
|
33065
33396
|
createVanaStorageProvider,
|
|
33066
33397
|
createViemPersonalServerLiteOwnerBindingSigner,
|
|
33067
33398
|
createViemPersonalServerRegistrationSigner,
|
|
33399
|
+
dataRegistryContractAddress,
|
|
33400
|
+
dataRegistryDomain,
|
|
33068
33401
|
decryptWithPassword,
|
|
33069
33402
|
deriveMasterKey,
|
|
33070
33403
|
deriveScopeKey,
|
|
33071
33404
|
deserializeECIES,
|
|
33072
33405
|
detectPlatform,
|
|
33406
|
+
encodeDepositNativeData,
|
|
33407
|
+
encodeDepositTokenData,
|
|
33408
|
+
encodeSetDataPointStatusData,
|
|
33073
33409
|
encryptWithPassword,
|
|
33074
|
-
|
|
33075
|
-
|
|
33410
|
+
escrowContractAddress,
|
|
33411
|
+
escrowPaymentDomain,
|
|
33076
33412
|
generatePkceVerifier,
|
|
33077
33413
|
genericPaymentDomain,
|
|
33078
33414
|
getAbi,
|
|
@@ -33081,6 +33417,8 @@ export {
|
|
|
33081
33417
|
getContractAddress,
|
|
33082
33418
|
getContractController,
|
|
33083
33419
|
getContractInfo,
|
|
33420
|
+
getFee,
|
|
33421
|
+
getOpFee,
|
|
33084
33422
|
getPlatformCapabilities,
|
|
33085
33423
|
getServiceEndpoints,
|
|
33086
33424
|
grantRegistrationDomain,
|
|
@@ -33092,11 +33430,12 @@ export {
|
|
|
33092
33430
|
moksha,
|
|
33093
33431
|
mokshaServices,
|
|
33094
33432
|
mokshaTestnet2 as mokshaTestnet,
|
|
33095
|
-
parseGrantRegistrationPayload,
|
|
33096
33433
|
parsePSError,
|
|
33097
33434
|
parseScope,
|
|
33098
33435
|
parseWeb3SignedHeader,
|
|
33436
|
+
personalServerDataReadPath,
|
|
33099
33437
|
personalServerRegistrationDomain,
|
|
33438
|
+
readPersonalServerData,
|
|
33100
33439
|
recoverServerOwner,
|
|
33101
33440
|
registerPersonalServerSignature,
|
|
33102
33441
|
scopeCoveredByGrant,
|