@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.node.js
CHANGED
|
@@ -29018,6 +29018,8 @@ async function buildWeb3SignedHeader(params) {
|
|
|
29018
29018
|
var DEFAULT_ENDPOINT = "https://storage.vana.org";
|
|
29019
29019
|
var BLOB_PATH_PREFIX = "/v1/blobs";
|
|
29020
29020
|
var DEFAULT_TOKEN_TTL_SECONDS = 300;
|
|
29021
|
+
var MAX_UPLOAD_ATTEMPTS = 4;
|
|
29022
|
+
var MAX_RATE_LIMIT_DELAY_MS = 3e4;
|
|
29021
29023
|
var VanaStorage = class {
|
|
29022
29024
|
endpoint;
|
|
29023
29025
|
signer;
|
|
@@ -29056,27 +29058,46 @@ var VanaStorage = class {
|
|
|
29056
29058
|
const body = new Uint8Array(await file.arrayBuffer());
|
|
29057
29059
|
const contentType = file.type !== "" ? file.type : "application/octet-stream";
|
|
29058
29060
|
const header = await this.signRequest("PUT", path, body);
|
|
29059
|
-
let response;
|
|
29060
|
-
|
|
29061
|
-
|
|
29062
|
-
|
|
29063
|
-
|
|
29064
|
-
|
|
29065
|
-
|
|
29066
|
-
|
|
29067
|
-
|
|
29068
|
-
|
|
29069
|
-
|
|
29061
|
+
let response = null;
|
|
29062
|
+
let responseText = "";
|
|
29063
|
+
for (let attempt = 1; attempt <= MAX_UPLOAD_ATTEMPTS; attempt++) {
|
|
29064
|
+
try {
|
|
29065
|
+
response = await this.fetchImpl(`${this.endpoint}${path}`, {
|
|
29066
|
+
method: "PUT",
|
|
29067
|
+
headers: {
|
|
29068
|
+
authorization: header,
|
|
29069
|
+
"content-type": contentType
|
|
29070
|
+
},
|
|
29071
|
+
body
|
|
29072
|
+
});
|
|
29073
|
+
} catch (cause) {
|
|
29074
|
+
throw new StorageError(
|
|
29075
|
+
`vana-storage upload network error: ${describe(cause)}`,
|
|
29076
|
+
"UPLOAD_ERROR",
|
|
29077
|
+
"vana-storage",
|
|
29078
|
+
{ cause: cause instanceof Error ? cause : void 0 }
|
|
29079
|
+
);
|
|
29080
|
+
}
|
|
29081
|
+
if (response.ok) {
|
|
29082
|
+
break;
|
|
29083
|
+
}
|
|
29084
|
+
responseText = await safeText(response);
|
|
29085
|
+
if (response.status === 429 && attempt < MAX_UPLOAD_ATTEMPTS) {
|
|
29086
|
+
const delayMs = retryDelayMs(response, responseText);
|
|
29087
|
+
if (delayMs > 0) {
|
|
29088
|
+
await sleep(delayMs);
|
|
29089
|
+
}
|
|
29090
|
+
continue;
|
|
29091
|
+
}
|
|
29070
29092
|
throw new StorageError(
|
|
29071
|
-
`vana-storage upload
|
|
29072
|
-
"
|
|
29073
|
-
"vana-storage"
|
|
29074
|
-
{ cause: cause instanceof Error ? cause : void 0 }
|
|
29093
|
+
`vana-storage upload failed: ${response.status} ${response.statusText} - ${responseText}`,
|
|
29094
|
+
"UPLOAD_FAILED",
|
|
29095
|
+
"vana-storage"
|
|
29075
29096
|
);
|
|
29076
29097
|
}
|
|
29077
|
-
if (!response
|
|
29098
|
+
if (!response?.ok) {
|
|
29078
29099
|
throw new StorageError(
|
|
29079
|
-
`vana-storage upload failed
|
|
29100
|
+
`vana-storage upload failed after ${MAX_UPLOAD_ATTEMPTS} attempts - ${responseText}`,
|
|
29080
29101
|
"UPLOAD_FAILED",
|
|
29081
29102
|
"vana-storage"
|
|
29082
29103
|
);
|
|
@@ -29229,6 +29250,43 @@ function describe(value) {
|
|
|
29229
29250
|
if (value instanceof Error) return value.message;
|
|
29230
29251
|
return String(value);
|
|
29231
29252
|
}
|
|
29253
|
+
function retryDelayMs(response, responseText) {
|
|
29254
|
+
const headerDelayMs = parseRetryAfterHeaderMs(
|
|
29255
|
+
response.headers.get("retry-after")
|
|
29256
|
+
);
|
|
29257
|
+
if (headerDelayMs !== null) {
|
|
29258
|
+
return clampRateLimitDelay(headerDelayMs);
|
|
29259
|
+
}
|
|
29260
|
+
return clampRateLimitDelay(parseRetryAfterBodyMs(responseText) ?? 0);
|
|
29261
|
+
}
|
|
29262
|
+
function parseRetryAfterHeaderMs(value) {
|
|
29263
|
+
if (!value) return null;
|
|
29264
|
+
const seconds = Number(value);
|
|
29265
|
+
if (Number.isFinite(seconds)) {
|
|
29266
|
+
return seconds * 1e3;
|
|
29267
|
+
}
|
|
29268
|
+
const dateMs = Date.parse(value);
|
|
29269
|
+
if (Number.isFinite(dateMs)) {
|
|
29270
|
+
return Math.max(0, dateMs - Date.now());
|
|
29271
|
+
}
|
|
29272
|
+
return null;
|
|
29273
|
+
}
|
|
29274
|
+
function parseRetryAfterBodyMs(responseText) {
|
|
29275
|
+
if (!responseText) return null;
|
|
29276
|
+
try {
|
|
29277
|
+
const parsed = JSON.parse(responseText);
|
|
29278
|
+
const seconds = Number(parsed.retryAfter);
|
|
29279
|
+
return Number.isFinite(seconds) ? seconds * 1e3 : null;
|
|
29280
|
+
} catch {
|
|
29281
|
+
return null;
|
|
29282
|
+
}
|
|
29283
|
+
}
|
|
29284
|
+
function clampRateLimitDelay(delayMs) {
|
|
29285
|
+
return Math.min(Math.max(0, delayMs), MAX_RATE_LIMIT_DELAY_MS);
|
|
29286
|
+
}
|
|
29287
|
+
function sleep(ms) {
|
|
29288
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
29289
|
+
}
|
|
29232
29290
|
async function safeText(response) {
|
|
29233
29291
|
try {
|
|
29234
29292
|
return await response.text();
|
|
@@ -32509,6 +32567,7 @@ function formatOAuthError(body, status) {
|
|
|
32509
32567
|
// src/protocol/eip712.ts
|
|
32510
32568
|
var DOMAIN_NAME = "Vana Data Portability";
|
|
32511
32569
|
var DOMAIN_VERSION = "1";
|
|
32570
|
+
var NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
|
|
32512
32571
|
function buildDomain(chainId, verifyingContract) {
|
|
32513
32572
|
return {
|
|
32514
32573
|
name: DOMAIN_NAME,
|
|
@@ -32517,13 +32576,7 @@ function buildDomain(chainId, verifyingContract) {
|
|
|
32517
32576
|
verifyingContract
|
|
32518
32577
|
};
|
|
32519
32578
|
}
|
|
32520
|
-
function
|
|
32521
|
-
return buildDomain(
|
|
32522
|
-
config.chainId,
|
|
32523
|
-
config.contracts.dataRegistry
|
|
32524
|
-
);
|
|
32525
|
-
}
|
|
32526
|
-
function fileDeletionDomain(config) {
|
|
32579
|
+
function dataRegistryDomain(config) {
|
|
32527
32580
|
return buildDomain(
|
|
32528
32581
|
config.chainId,
|
|
32529
32582
|
config.contracts.dataRegistry
|
|
@@ -32553,31 +32606,26 @@ function builderRegistrationDomain(config) {
|
|
|
32553
32606
|
config.contracts.dataPortabilityGrantees
|
|
32554
32607
|
);
|
|
32555
32608
|
}
|
|
32556
|
-
|
|
32557
|
-
|
|
32558
|
-
|
|
32559
|
-
|
|
32560
|
-
|
|
32561
|
-
|
|
32562
|
-
};
|
|
32563
|
-
var FILE_DELETION_TYPES = {
|
|
32564
|
-
FileDeletion: [
|
|
32565
|
-
{ name: "ownerAddress", type: "address" },
|
|
32566
|
-
{ name: "fileId", type: "bytes32" }
|
|
32567
|
-
]
|
|
32568
|
-
};
|
|
32609
|
+
function escrowPaymentDomain(config) {
|
|
32610
|
+
return buildDomain(
|
|
32611
|
+
config.chainId,
|
|
32612
|
+
config.contracts.dataPortabilityEscrow
|
|
32613
|
+
);
|
|
32614
|
+
}
|
|
32569
32615
|
var GRANT_REGISTRATION_TYPES = {
|
|
32570
32616
|
GrantRegistration: [
|
|
32571
32617
|
{ name: "grantorAddress", type: "address" },
|
|
32572
32618
|
{ name: "granteeId", type: "bytes32" },
|
|
32573
|
-
{ name: "
|
|
32574
|
-
{ name: "
|
|
32619
|
+
{ name: "scopes", type: "string[]" },
|
|
32620
|
+
{ name: "grantVersion", type: "uint256" },
|
|
32621
|
+
{ name: "expiresAt", type: "uint256" }
|
|
32575
32622
|
]
|
|
32576
32623
|
};
|
|
32577
32624
|
var GRANT_REVOCATION_TYPES = {
|
|
32578
32625
|
GrantRevocation: [
|
|
32579
32626
|
{ name: "grantorAddress", type: "address" },
|
|
32580
|
-
{ name: "grantId", type: "bytes32" }
|
|
32627
|
+
{ name: "grantId", type: "bytes32" },
|
|
32628
|
+
{ name: "grantVersion", type: "uint256" }
|
|
32581
32629
|
]
|
|
32582
32630
|
};
|
|
32583
32631
|
var SERVER_REGISTRATION_TYPES = {
|
|
@@ -32596,6 +32644,24 @@ var BUILDER_REGISTRATION_TYPES = {
|
|
|
32596
32644
|
{ name: "appUrl", type: "string" }
|
|
32597
32645
|
]
|
|
32598
32646
|
};
|
|
32647
|
+
var ADD_DATA_TYPES = {
|
|
32648
|
+
AddData: [
|
|
32649
|
+
{ name: "ownerAddress", type: "address" },
|
|
32650
|
+
{ name: "scope", type: "string" },
|
|
32651
|
+
{ name: "dataHash", type: "bytes32" },
|
|
32652
|
+
{ name: "metadataHash", type: "bytes32" },
|
|
32653
|
+
{ name: "expectedVersion", type: "uint256" }
|
|
32654
|
+
]
|
|
32655
|
+
};
|
|
32656
|
+
var RECORD_DATA_ACCESS_TYPES = {
|
|
32657
|
+
RecordDataAccess: [
|
|
32658
|
+
{ name: "ownerAddress", type: "address" },
|
|
32659
|
+
{ name: "scope", type: "string" },
|
|
32660
|
+
{ name: "version", type: "uint256" },
|
|
32661
|
+
{ name: "accessor", type: "address" },
|
|
32662
|
+
{ name: "recordId", type: "bytes32" }
|
|
32663
|
+
]
|
|
32664
|
+
};
|
|
32599
32665
|
|
|
32600
32666
|
// src/protocol/personal-server-registration.ts
|
|
32601
32667
|
import {
|
|
@@ -33047,67 +33113,34 @@ function isDataPortabilityGatewayConfig(value) {
|
|
|
33047
33113
|
return false;
|
|
33048
33114
|
}
|
|
33049
33115
|
const c = contracts;
|
|
33050
|
-
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]);
|
|
33051
|
-
}
|
|
33052
|
-
function parseGrantRegistrationPayload(grant) {
|
|
33053
|
-
let parsed;
|
|
33054
|
-
try {
|
|
33055
|
-
parsed = JSON.parse(grant);
|
|
33056
|
-
} catch {
|
|
33057
|
-
return null;
|
|
33058
|
-
}
|
|
33059
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
33060
|
-
return null;
|
|
33061
|
-
}
|
|
33062
|
-
const value = parsed;
|
|
33063
|
-
if (!Array.isArray(value["scopes"]) || value["scopes"].length === 0) {
|
|
33064
|
-
return null;
|
|
33065
|
-
}
|
|
33066
|
-
if (!value["scopes"].every((scope) => typeof scope === "string")) {
|
|
33067
|
-
return null;
|
|
33068
|
-
}
|
|
33069
|
-
if (typeof value["expiresAt"] !== "number" || !Number.isFinite(value["expiresAt"])) {
|
|
33070
|
-
return null;
|
|
33071
|
-
}
|
|
33072
|
-
if (value["user"] !== void 0 && !isHexString(value["user"])) {
|
|
33073
|
-
return null;
|
|
33074
|
-
}
|
|
33075
|
-
if (value["builder"] !== void 0 && !isHexString(value["builder"])) {
|
|
33076
|
-
return null;
|
|
33077
|
-
}
|
|
33078
|
-
if (value["nonce"] !== void 0 && (typeof value["nonce"] !== "number" || !Number.isFinite(value["nonce"]))) {
|
|
33079
|
-
return null;
|
|
33080
|
-
}
|
|
33081
|
-
return {
|
|
33082
|
-
user: value["user"],
|
|
33083
|
-
builder: value["builder"],
|
|
33084
|
-
scopes: value["scopes"],
|
|
33085
|
-
expiresAt: value["expiresAt"],
|
|
33086
|
-
nonce: value["nonce"]
|
|
33087
|
-
};
|
|
33116
|
+
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]) && isHexString(c["dataPortabilityEscrow"]) && isHexString(c["feeRegistry"]);
|
|
33088
33117
|
}
|
|
33089
|
-
function
|
|
33118
|
+
function toUint256(value) {
|
|
33090
33119
|
try {
|
|
33091
|
-
|
|
33092
|
-
|
|
33093
|
-
|
|
33094
|
-
|
|
33095
|
-
|
|
33120
|
+
if (typeof value === "number" && !Number.isSafeInteger(value)) {
|
|
33121
|
+
return null;
|
|
33122
|
+
}
|
|
33123
|
+
const big = typeof value === "bigint" ? value : BigInt(value);
|
|
33124
|
+
if (big < 0n) return null;
|
|
33125
|
+
return big;
|
|
33096
33126
|
} catch {
|
|
33097
33127
|
return null;
|
|
33098
33128
|
}
|
|
33099
33129
|
}
|
|
33100
33130
|
async function verifyGrantRegistration(input) {
|
|
33101
|
-
|
|
33102
|
-
|
|
33103
|
-
|
|
33104
|
-
|
|
33105
|
-
|
|
33106
|
-
};
|
|
33131
|
+
if (!Array.isArray(input.scopes) || input.scopes.length === 0) {
|
|
33132
|
+
return { valid: false, error: "scopes must be a non-empty array" };
|
|
33133
|
+
}
|
|
33134
|
+
if (!input.scopes.every((scope) => typeof scope === "string")) {
|
|
33135
|
+
return { valid: false, error: "scopes must contain only strings" };
|
|
33107
33136
|
}
|
|
33108
|
-
const
|
|
33109
|
-
if (
|
|
33110
|
-
return { valid: false, error: "
|
|
33137
|
+
const grantVersion = toUint256(input.grantVersion);
|
|
33138
|
+
if (grantVersion === null || grantVersion < 1n) {
|
|
33139
|
+
return { valid: false, error: "grantVersion must be a uint256 >= 1" };
|
|
33140
|
+
}
|
|
33141
|
+
const expiresAt = toUint256(input.expiresAt);
|
|
33142
|
+
if (expiresAt === null) {
|
|
33143
|
+
return { valid: false, error: "expiresAt must be a non-negative uint256" };
|
|
33111
33144
|
}
|
|
33112
33145
|
let valid;
|
|
33113
33146
|
try {
|
|
@@ -33119,8 +33152,9 @@ async function verifyGrantRegistration(input) {
|
|
|
33119
33152
|
message: {
|
|
33120
33153
|
grantorAddress: input.grantorAddress,
|
|
33121
33154
|
granteeId: input.granteeId,
|
|
33122
|
-
|
|
33123
|
-
|
|
33155
|
+
scopes: input.scopes,
|
|
33156
|
+
grantVersion,
|
|
33157
|
+
expiresAt
|
|
33124
33158
|
},
|
|
33125
33159
|
signature: input.signature
|
|
33126
33160
|
});
|
|
@@ -33131,26 +33165,269 @@ async function verifyGrantRegistration(input) {
|
|
|
33131
33165
|
return { valid: false, error: "Grant signature does not match grantor" };
|
|
33132
33166
|
}
|
|
33133
33167
|
const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
|
|
33134
|
-
if (
|
|
33168
|
+
if (expiresAt > 0n && expiresAt < BigInt(nowSeconds)) {
|
|
33135
33169
|
return { valid: false, error: "Grant has expired" };
|
|
33136
33170
|
}
|
|
33137
|
-
if (payload.user !== void 0 && payload.user.toLowerCase() !== input.grantorAddress.toLowerCase()) {
|
|
33138
|
-
return { valid: false, error: "Grant user does not match grantorAddress" };
|
|
33139
|
-
}
|
|
33140
33171
|
return {
|
|
33141
33172
|
valid: true,
|
|
33142
33173
|
grantorAddress: input.grantorAddress,
|
|
33143
33174
|
granteeId: input.granteeId,
|
|
33144
|
-
|
|
33145
|
-
|
|
33146
|
-
|
|
33175
|
+
scopes: input.scopes,
|
|
33176
|
+
grantVersion: grantVersion.toString(),
|
|
33177
|
+
expiresAt: expiresAt.toString()
|
|
33147
33178
|
};
|
|
33148
33179
|
}
|
|
33149
33180
|
|
|
33150
|
-
// src/protocol/
|
|
33181
|
+
// src/protocol/fee-registry.ts
|
|
33182
|
+
import { parseAbi } from "viem";
|
|
33183
|
+
var FEE_REGISTRY_ABI = parseAbi([
|
|
33184
|
+
"struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
|
|
33185
|
+
"function fees(bytes32 operation) view returns (Fee)",
|
|
33186
|
+
"function operationKey(string name) pure returns (bytes32)"
|
|
33187
|
+
]);
|
|
33188
|
+
var REGISTRATION_KIND_FOR_OP = {
|
|
33189
|
+
grant: "grant_registration",
|
|
33190
|
+
data: "data_registration",
|
|
33191
|
+
server: "server_registration",
|
|
33192
|
+
builder: "builder_registration"
|
|
33193
|
+
};
|
|
33194
|
+
function operationNameFor(kind, opts) {
|
|
33195
|
+
switch (kind) {
|
|
33196
|
+
case "grant_registration":
|
|
33197
|
+
return opts?.grantRegistrationOpName ?? "grant_registration";
|
|
33198
|
+
case "data_access":
|
|
33199
|
+
return opts?.dataAccessOpName ?? "data_access";
|
|
33200
|
+
case "data_registration":
|
|
33201
|
+
return opts?.dataRegistrationOpName ?? "data_registration";
|
|
33202
|
+
case "server_registration":
|
|
33203
|
+
return opts?.serverRegistrationOpName ?? "server_registration";
|
|
33204
|
+
case "builder_registration":
|
|
33205
|
+
return opts?.builderRegistrationOpName ?? "builder_registration";
|
|
33206
|
+
}
|
|
33207
|
+
}
|
|
33208
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
33209
|
+
async function getFee(client, config, kind, opts) {
|
|
33210
|
+
const address = config.contracts.feeRegistry;
|
|
33211
|
+
const opName = operationNameFor(kind, opts);
|
|
33212
|
+
const opKey = await client.readContract({
|
|
33213
|
+
address,
|
|
33214
|
+
abi: FEE_REGISTRY_ABI,
|
|
33215
|
+
functionName: "operationKey",
|
|
33216
|
+
args: [opName]
|
|
33217
|
+
});
|
|
33218
|
+
const fee = await client.readContract({
|
|
33219
|
+
address,
|
|
33220
|
+
abi: FEE_REGISTRY_ABI,
|
|
33221
|
+
functionName: "fees",
|
|
33222
|
+
args: [opKey]
|
|
33223
|
+
});
|
|
33224
|
+
if (fee.enabled && fee.payee === ZERO_ADDRESS) {
|
|
33225
|
+
throw new Error(
|
|
33226
|
+
`FeeRegistry: enabled operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
|
|
33227
|
+
);
|
|
33228
|
+
}
|
|
33229
|
+
return fee;
|
|
33230
|
+
}
|
|
33231
|
+
async function getOpFee(client, config, opType, opts) {
|
|
33232
|
+
const registrationKind = REGISTRATION_KIND_FOR_OP[opType];
|
|
33233
|
+
if (!registrationKind) {
|
|
33234
|
+
throw new Error(
|
|
33235
|
+
`getOpFee: unknown opType "${opType}" \u2014 supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(", ")}`
|
|
33236
|
+
);
|
|
33237
|
+
}
|
|
33238
|
+
const includeDataAccess = opType === "grant";
|
|
33239
|
+
const [registration, dataAccess] = await Promise.all([
|
|
33240
|
+
getFee(client, config, registrationKind, opts),
|
|
33241
|
+
includeDataAccess ? getFee(client, config, "data_access", opts) : Promise.resolve({
|
|
33242
|
+
amount: 0n,
|
|
33243
|
+
asset: ZERO_ADDRESS,
|
|
33244
|
+
payee: ZERO_ADDRESS,
|
|
33245
|
+
enabled: false
|
|
33246
|
+
})
|
|
33247
|
+
]);
|
|
33248
|
+
if (registration.enabled && dataAccess.enabled && registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
|
|
33249
|
+
throw new Error(
|
|
33250
|
+
`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.`
|
|
33251
|
+
);
|
|
33252
|
+
}
|
|
33253
|
+
const asset = registration.enabled ? registration.asset : dataAccess.enabled ? dataAccess.asset : ZERO_ADDRESS;
|
|
33254
|
+
return {
|
|
33255
|
+
asset,
|
|
33256
|
+
registrationFee: registration.enabled ? registration.amount : 0n,
|
|
33257
|
+
dataAccessFee: dataAccess.enabled ? dataAccess.amount : 0n,
|
|
33258
|
+
registrationEnabled: registration.enabled,
|
|
33259
|
+
dataAccessEnabled: dataAccess.enabled,
|
|
33260
|
+
registrationPayee: registration.enabled ? registration.payee : ZERO_ADDRESS,
|
|
33261
|
+
dataAccessPayee: dataAccess.enabled ? dataAccess.payee : ZERO_ADDRESS
|
|
33262
|
+
};
|
|
33263
|
+
}
|
|
33264
|
+
|
|
33265
|
+
// src/protocol/escrow-deposit.ts
|
|
33266
|
+
import { encodeFunctionData } from "viem";
|
|
33267
|
+
var ESCROW_DEPOSIT_ABI = [
|
|
33268
|
+
{
|
|
33269
|
+
type: "function",
|
|
33270
|
+
name: "depositNative",
|
|
33271
|
+
stateMutability: "payable",
|
|
33272
|
+
inputs: [{ name: "account", type: "address" }],
|
|
33273
|
+
outputs: []
|
|
33274
|
+
},
|
|
33275
|
+
{
|
|
33276
|
+
type: "function",
|
|
33277
|
+
name: "depositToken",
|
|
33278
|
+
stateMutability: "nonpayable",
|
|
33279
|
+
inputs: [
|
|
33280
|
+
{ name: "account", type: "address" },
|
|
33281
|
+
{ name: "token", type: "address" },
|
|
33282
|
+
{ name: "amount", type: "uint256" }
|
|
33283
|
+
],
|
|
33284
|
+
outputs: []
|
|
33285
|
+
}
|
|
33286
|
+
];
|
|
33287
|
+
function escrowContractAddress(config) {
|
|
33288
|
+
return config.contracts.dataPortabilityEscrow;
|
|
33289
|
+
}
|
|
33290
|
+
function encodeDepositNativeData(input) {
|
|
33291
|
+
return encodeFunctionData({
|
|
33292
|
+
abi: ESCROW_DEPOSIT_ABI,
|
|
33293
|
+
functionName: "depositNative",
|
|
33294
|
+
args: [input.account]
|
|
33295
|
+
});
|
|
33296
|
+
}
|
|
33297
|
+
function encodeDepositTokenData(input) {
|
|
33298
|
+
return encodeFunctionData({
|
|
33299
|
+
abi: ESCROW_DEPOSIT_ABI,
|
|
33300
|
+
functionName: "depositToken",
|
|
33301
|
+
args: [input.account, input.token, input.amount]
|
|
33302
|
+
});
|
|
33303
|
+
}
|
|
33304
|
+
function buildDepositNativeRequest(config, input) {
|
|
33305
|
+
return {
|
|
33306
|
+
to: escrowContractAddress(config),
|
|
33307
|
+
data: encodeDepositNativeData({ account: input.account }),
|
|
33308
|
+
value: input.amount
|
|
33309
|
+
};
|
|
33310
|
+
}
|
|
33311
|
+
function buildDepositTokenRequest(config, input) {
|
|
33312
|
+
return {
|
|
33313
|
+
to: escrowContractAddress(config),
|
|
33314
|
+
data: encodeDepositTokenData(input)
|
|
33315
|
+
};
|
|
33316
|
+
}
|
|
33317
|
+
|
|
33318
|
+
// src/protocol/data-point-status.ts
|
|
33319
|
+
import { encodeFunctionData as encodeFunctionData2 } from "viem";
|
|
33320
|
+
var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
|
|
33321
|
+
DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
|
|
33322
|
+
DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
|
|
33323
|
+
DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
|
|
33324
|
+
DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
|
|
33325
|
+
return DataPointStatus2;
|
|
33326
|
+
})(DataPointStatus || {});
|
|
33327
|
+
var DATA_REGISTRY_STATUS_ABI = [
|
|
33328
|
+
{
|
|
33329
|
+
type: "function",
|
|
33330
|
+
name: "setStatus",
|
|
33331
|
+
stateMutability: "nonpayable",
|
|
33332
|
+
inputs: [
|
|
33333
|
+
{ name: "scope", type: "string" },
|
|
33334
|
+
{ name: "newStatus", type: "uint8" }
|
|
33335
|
+
],
|
|
33336
|
+
outputs: []
|
|
33337
|
+
}
|
|
33338
|
+
];
|
|
33339
|
+
function dataRegistryContractAddress(config) {
|
|
33340
|
+
return config.contracts.dataRegistry;
|
|
33341
|
+
}
|
|
33342
|
+
function encodeSetDataPointStatusData(input) {
|
|
33343
|
+
return encodeFunctionData2({
|
|
33344
|
+
abi: DATA_REGISTRY_STATUS_ABI,
|
|
33345
|
+
functionName: "setStatus",
|
|
33346
|
+
args: [input.scope, input.status]
|
|
33347
|
+
});
|
|
33348
|
+
}
|
|
33349
|
+
function buildSetDataPointStatusRequest(config, input) {
|
|
33350
|
+
return {
|
|
33351
|
+
to: dataRegistryContractAddress(config),
|
|
33352
|
+
data: encodeSetDataPointStatusData(input)
|
|
33353
|
+
};
|
|
33354
|
+
}
|
|
33355
|
+
function buildMarkDataPointUnavailableRequest(config, input) {
|
|
33356
|
+
return buildSetDataPointStatusRequest(config, {
|
|
33357
|
+
scope: input.scope,
|
|
33358
|
+
status: 3 /* Unavailable */
|
|
33359
|
+
});
|
|
33360
|
+
}
|
|
33361
|
+
|
|
33362
|
+
// src/protocol/data-file.ts
|
|
33151
33363
|
import { z } from "zod";
|
|
33364
|
+
var DataFileEnvelopeSchema = z.object({
|
|
33365
|
+
$schema: z.string().url().optional(),
|
|
33366
|
+
version: z.literal("1.0"),
|
|
33367
|
+
scope: z.string(),
|
|
33368
|
+
schemaId: z.string().optional(),
|
|
33369
|
+
collectedAt: z.string().datetime(),
|
|
33370
|
+
data: z.record(z.string(), z.unknown())
|
|
33371
|
+
});
|
|
33372
|
+
function createDataFileEnvelope(scope, collectedAt, data, schemaUrl, schemaId) {
|
|
33373
|
+
return {
|
|
33374
|
+
...schemaUrl !== void 0 && { $schema: schemaUrl },
|
|
33375
|
+
...schemaId !== void 0 && { schemaId },
|
|
33376
|
+
version: "1.0",
|
|
33377
|
+
scope,
|
|
33378
|
+
collectedAt,
|
|
33379
|
+
data
|
|
33380
|
+
};
|
|
33381
|
+
}
|
|
33382
|
+
var IngestResponseSchema = z.object({
|
|
33383
|
+
scope: z.string(),
|
|
33384
|
+
collectedAt: z.string().datetime(),
|
|
33385
|
+
status: z.enum(["stored", "syncing"])
|
|
33386
|
+
});
|
|
33387
|
+
|
|
33388
|
+
// src/protocol/personal-server-data.ts
|
|
33389
|
+
function personalServerDataReadPath(scope) {
|
|
33390
|
+
return `/v1/data/${encodeURIComponent(scope)}`;
|
|
33391
|
+
}
|
|
33392
|
+
async function buildPersonalServerDataReadRequest(params) {
|
|
33393
|
+
const path = personalServerDataReadPath(params.scope);
|
|
33394
|
+
const baseUrl = params.personalServerUrl.replace(/\/+$/, "");
|
|
33395
|
+
const audience = params.audience ?? baseUrl;
|
|
33396
|
+
const headers = new Headers(params.headers);
|
|
33397
|
+
headers.set(
|
|
33398
|
+
"Authorization",
|
|
33399
|
+
await buildWeb3SignedHeader({
|
|
33400
|
+
aud: audience,
|
|
33401
|
+
grantId: params.grantId,
|
|
33402
|
+
method: "GET",
|
|
33403
|
+
signMessage: params.signMessage,
|
|
33404
|
+
uri: path
|
|
33405
|
+
})
|
|
33406
|
+
);
|
|
33407
|
+
return new Request(`${baseUrl}${path}`, {
|
|
33408
|
+
headers,
|
|
33409
|
+
method: "GET"
|
|
33410
|
+
});
|
|
33411
|
+
}
|
|
33412
|
+
async function readPersonalServerData(params) {
|
|
33413
|
+
const fetchFn = params.fetch ?? globalThis.fetch;
|
|
33414
|
+
if (fetchFn === void 0) {
|
|
33415
|
+
throw new Error("No fetch implementation available");
|
|
33416
|
+
}
|
|
33417
|
+
const request = await buildPersonalServerDataReadRequest(params);
|
|
33418
|
+
const response = await fetchFn(request);
|
|
33419
|
+
if (!response.ok) {
|
|
33420
|
+
throw new Error(
|
|
33421
|
+
`Personal Server data read failed: ${response.status} ${response.statusText}`
|
|
33422
|
+
);
|
|
33423
|
+
}
|
|
33424
|
+
return DataFileEnvelopeSchema.parse(await response.json());
|
|
33425
|
+
}
|
|
33426
|
+
|
|
33427
|
+
// src/protocol/scopes.ts
|
|
33428
|
+
import { z as z2 } from "zod";
|
|
33152
33429
|
var SEGMENT_RE = /^[a-z0-9][a-z0-9_]*$/;
|
|
33153
|
-
var ScopeSchema =
|
|
33430
|
+
var ScopeSchema = z2.string().refine(
|
|
33154
33431
|
(scope) => {
|
|
33155
33432
|
const parts = scope.split(".");
|
|
33156
33433
|
return parts.length >= 2 && parts.length <= 3 && parts.every((part) => SEGMENT_RE.test(part));
|
|
@@ -33191,32 +33468,6 @@ function scopeCoveredByGrant(requestedScope, grantedScopes) {
|
|
|
33191
33468
|
);
|
|
33192
33469
|
}
|
|
33193
33470
|
|
|
33194
|
-
// src/protocol/data-file.ts
|
|
33195
|
-
import { z as z2 } from "zod";
|
|
33196
|
-
var DataFileEnvelopeSchema = z2.object({
|
|
33197
|
-
$schema: z2.string().url().optional(),
|
|
33198
|
-
version: z2.literal("1.0"),
|
|
33199
|
-
scope: z2.string(),
|
|
33200
|
-
schemaId: z2.string().optional(),
|
|
33201
|
-
collectedAt: z2.string().datetime(),
|
|
33202
|
-
data: z2.record(z2.string(), z2.unknown())
|
|
33203
|
-
});
|
|
33204
|
-
function createDataFileEnvelope(scope, collectedAt, data, schemaUrl, schemaId) {
|
|
33205
|
-
return {
|
|
33206
|
-
...schemaUrl !== void 0 && { $schema: schemaUrl },
|
|
33207
|
-
...schemaId !== void 0 && { schemaId },
|
|
33208
|
-
version: "1.0",
|
|
33209
|
-
scope,
|
|
33210
|
-
collectedAt,
|
|
33211
|
-
data
|
|
33212
|
-
};
|
|
33213
|
-
}
|
|
33214
|
-
var IngestResponseSchema = z2.object({
|
|
33215
|
-
scope: z2.string(),
|
|
33216
|
-
collectedAt: z2.string().datetime(),
|
|
33217
|
-
status: z2.enum(["stored", "syncing"])
|
|
33218
|
-
});
|
|
33219
|
-
|
|
33220
33471
|
// src/protocol/gateway.ts
|
|
33221
33472
|
function createGatewayClient(baseUrl) {
|
|
33222
33473
|
const base = baseUrl.replace(/\/+$/, "");
|
|
@@ -33224,16 +33475,6 @@ function createGatewayClient(baseUrl) {
|
|
|
33224
33475
|
const envelope = await res.json();
|
|
33225
33476
|
return envelope.data;
|
|
33226
33477
|
}
|
|
33227
|
-
function normalizeFileRecord(record) {
|
|
33228
|
-
return {
|
|
33229
|
-
fileId: record.fileId ?? record.id ?? "",
|
|
33230
|
-
owner: record.owner ?? record.ownerAddress ?? "",
|
|
33231
|
-
url: record.url,
|
|
33232
|
-
schemaId: record.schemaId,
|
|
33233
|
-
createdAt: record.createdAt ?? record.addedAt ?? "",
|
|
33234
|
-
deletedAt: record.deletedAt ?? null
|
|
33235
|
-
};
|
|
33236
|
-
}
|
|
33237
33478
|
function getMutationId(body, key) {
|
|
33238
33479
|
const value = body[key] ?? body["id"];
|
|
33239
33480
|
return typeof value === "string" ? value : void 0;
|
|
@@ -33283,31 +33524,33 @@ function createGatewayClient(baseUrl) {
|
|
|
33283
33524
|
}
|
|
33284
33525
|
return unwrapEnvelope(res);
|
|
33285
33526
|
},
|
|
33286
|
-
async
|
|
33287
|
-
const res = await fetch(`${base}/v1/
|
|
33527
|
+
async getDataPoint(dataPointId) {
|
|
33528
|
+
const res = await fetch(`${base}/v1/data/${dataPointId}`);
|
|
33288
33529
|
if (res.status === 404) return null;
|
|
33289
33530
|
if (!res.ok) {
|
|
33290
33531
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33291
33532
|
}
|
|
33292
|
-
return
|
|
33533
|
+
return unwrapEnvelope(res);
|
|
33293
33534
|
},
|
|
33294
|
-
async
|
|
33535
|
+
async listDataPointsByOwner(owner, cursor, options) {
|
|
33295
33536
|
const params = new URLSearchParams({ user: owner });
|
|
33296
33537
|
if (cursor !== null) {
|
|
33297
33538
|
params.set("cursor", cursor);
|
|
33298
33539
|
}
|
|
33299
|
-
if (options?.
|
|
33300
|
-
params.set("
|
|
33540
|
+
if (options?.since) {
|
|
33541
|
+
params.set("since", options.since);
|
|
33542
|
+
}
|
|
33543
|
+
if (options?.limit !== void 0) {
|
|
33544
|
+
params.set("limit", String(options.limit));
|
|
33301
33545
|
}
|
|
33302
|
-
const res = await fetch(`${base}/v1/
|
|
33546
|
+
const res = await fetch(`${base}/v1/data?${params.toString()}`);
|
|
33303
33547
|
if (!res.ok) {
|
|
33304
33548
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33305
33549
|
}
|
|
33306
33550
|
const envelope = await res.json();
|
|
33307
|
-
const
|
|
33308
|
-
const nextCursor = pagination?.hasMore === false ? null : pagination?.nextCursor ?? envelope.data.cursor ?? null;
|
|
33551
|
+
const nextCursor = envelope.pagination?.hasMore === false ? null : envelope.pagination?.nextCursor ?? null;
|
|
33309
33552
|
return {
|
|
33310
|
-
|
|
33553
|
+
dataPoints: envelope.data.dataPoints,
|
|
33311
33554
|
cursor: nextCursor
|
|
33312
33555
|
};
|
|
33313
33556
|
},
|
|
@@ -33349,8 +33592,8 @@ function createGatewayClient(baseUrl) {
|
|
|
33349
33592
|
alreadyRegistered: false
|
|
33350
33593
|
};
|
|
33351
33594
|
},
|
|
33352
|
-
async
|
|
33353
|
-
const res = await fetch(`${base}/v1/
|
|
33595
|
+
async registerBuilder(params) {
|
|
33596
|
+
const res = await fetch(`${base}/v1/builders`, {
|
|
33354
33597
|
method: "POST",
|
|
33355
33598
|
headers: {
|
|
33356
33599
|
"Content-Type": "application/json",
|
|
@@ -33358,22 +33601,57 @@ function createGatewayClient(baseUrl) {
|
|
|
33358
33601
|
},
|
|
33359
33602
|
body: JSON.stringify({
|
|
33360
33603
|
ownerAddress: params.ownerAddress,
|
|
33361
|
-
|
|
33362
|
-
|
|
33604
|
+
granteeAddress: params.granteeAddress,
|
|
33605
|
+
publicKey: params.publicKey,
|
|
33606
|
+
appUrl: params.appUrl
|
|
33363
33607
|
})
|
|
33364
33608
|
});
|
|
33365
33609
|
if (res.status === 409) {
|
|
33366
33610
|
const body2 = await res.json().catch(() => ({}));
|
|
33367
33611
|
return {
|
|
33368
|
-
|
|
33612
|
+
builderId: getMutationId(
|
|
33613
|
+
body2,
|
|
33614
|
+
"builderId"
|
|
33615
|
+
),
|
|
33616
|
+
alreadyRegistered: true
|
|
33369
33617
|
};
|
|
33370
33618
|
}
|
|
33371
33619
|
if (!res.ok) {
|
|
33372
33620
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33373
33621
|
}
|
|
33374
|
-
const body = await res.json();
|
|
33622
|
+
const body = await res.json().catch(() => ({}));
|
|
33375
33623
|
return {
|
|
33376
|
-
|
|
33624
|
+
builderId: getMutationId(body, "builderId"),
|
|
33625
|
+
alreadyRegistered: false
|
|
33626
|
+
};
|
|
33627
|
+
},
|
|
33628
|
+
async registerDataPoint(params) {
|
|
33629
|
+
const res = await fetch(`${base}/v1/data`, {
|
|
33630
|
+
method: "POST",
|
|
33631
|
+
headers: {
|
|
33632
|
+
"Content-Type": "application/json",
|
|
33633
|
+
Authorization: `Web3Signed ${params.signature}`
|
|
33634
|
+
},
|
|
33635
|
+
body: JSON.stringify({
|
|
33636
|
+
ownerAddress: params.ownerAddress,
|
|
33637
|
+
scope: params.scope,
|
|
33638
|
+
dataHash: params.dataHash,
|
|
33639
|
+
metadataHash: params.metadataHash,
|
|
33640
|
+
expectedVersion: params.expectedVersion
|
|
33641
|
+
})
|
|
33642
|
+
});
|
|
33643
|
+
if (!res.ok) {
|
|
33644
|
+
const body2 = await res.json().catch(() => ({}));
|
|
33645
|
+
const detail = body2.error ?? res.statusText;
|
|
33646
|
+
throw new Error(`Gateway error: ${res.status} ${detail}`);
|
|
33647
|
+
}
|
|
33648
|
+
const body = await res.json().catch(() => ({}));
|
|
33649
|
+
return {
|
|
33650
|
+
dataPointId: getMutationId(
|
|
33651
|
+
body,
|
|
33652
|
+
"dataPointId"
|
|
33653
|
+
),
|
|
33654
|
+
expectedVersion: body.expectedVersion
|
|
33377
33655
|
};
|
|
33378
33656
|
},
|
|
33379
33657
|
async createGrant(params) {
|
|
@@ -33386,8 +33664,9 @@ function createGatewayClient(baseUrl) {
|
|
|
33386
33664
|
body: JSON.stringify({
|
|
33387
33665
|
grantorAddress: params.grantorAddress,
|
|
33388
33666
|
granteeId: params.granteeId,
|
|
33389
|
-
|
|
33390
|
-
|
|
33667
|
+
scopes: params.scopes,
|
|
33668
|
+
grantVersion: params.grantVersion,
|
|
33669
|
+
expiresAt: params.expiresAt
|
|
33391
33670
|
})
|
|
33392
33671
|
});
|
|
33393
33672
|
if (res.status === 409) {
|
|
@@ -33412,7 +33691,8 @@ function createGatewayClient(baseUrl) {
|
|
|
33412
33691
|
Authorization: `Web3Signed ${params.signature}`
|
|
33413
33692
|
},
|
|
33414
33693
|
body: JSON.stringify({
|
|
33415
|
-
grantorAddress: params.grantorAddress
|
|
33694
|
+
grantorAddress: params.grantorAddress,
|
|
33695
|
+
grantVersion: params.grantVersion
|
|
33416
33696
|
})
|
|
33417
33697
|
});
|
|
33418
33698
|
if (res.status === 409) return;
|
|
@@ -33420,21 +33700,62 @@ function createGatewayClient(baseUrl) {
|
|
|
33420
33700
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33421
33701
|
}
|
|
33422
33702
|
},
|
|
33423
|
-
async
|
|
33424
|
-
const res = await fetch(`${base}/v1/
|
|
33425
|
-
|
|
33703
|
+
async getEscrowBalance(account) {
|
|
33704
|
+
const res = await fetch(`${base}/v1/escrow/balance?account=${account}`);
|
|
33705
|
+
if (!res.ok) {
|
|
33706
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33707
|
+
}
|
|
33708
|
+
return await res.json();
|
|
33709
|
+
},
|
|
33710
|
+
async submitEscrowDeposit(params) {
|
|
33711
|
+
const res = await fetch(`${base}/v1/escrow/deposit`, {
|
|
33712
|
+
method: "POST",
|
|
33713
|
+
headers: { "Content-Type": "application/json" },
|
|
33714
|
+
body: JSON.stringify({ txHash: params.txHash })
|
|
33715
|
+
});
|
|
33716
|
+
if (res.status !== 200 && res.status !== 202) {
|
|
33717
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33718
|
+
}
|
|
33719
|
+
return await res.json();
|
|
33720
|
+
},
|
|
33721
|
+
async payForOperation(params) {
|
|
33722
|
+
const body = {
|
|
33723
|
+
payerAddress: params.payerAddress,
|
|
33724
|
+
opType: params.opType,
|
|
33725
|
+
opId: params.opId,
|
|
33726
|
+
asset: params.asset,
|
|
33727
|
+
amount: params.amount,
|
|
33728
|
+
paymentNonce: params.paymentNonce
|
|
33729
|
+
};
|
|
33730
|
+
if (params.accessRecord) {
|
|
33731
|
+
body["accessRecord"] = params.accessRecord;
|
|
33732
|
+
}
|
|
33733
|
+
const res = await fetch(`${base}/v1/escrow/pay`, {
|
|
33734
|
+
method: "POST",
|
|
33426
33735
|
headers: {
|
|
33427
33736
|
"Content-Type": "application/json",
|
|
33428
33737
|
Authorization: `Web3Signed ${params.signature}`
|
|
33429
33738
|
},
|
|
33430
|
-
body: JSON.stringify(
|
|
33431
|
-
ownerAddress: params.ownerAddress
|
|
33432
|
-
})
|
|
33739
|
+
body: JSON.stringify(body)
|
|
33433
33740
|
});
|
|
33434
|
-
if (res.status === 409) return;
|
|
33435
33741
|
if (!res.ok) {
|
|
33436
33742
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33437
33743
|
}
|
|
33744
|
+
return await res.json();
|
|
33745
|
+
},
|
|
33746
|
+
async settle(params) {
|
|
33747
|
+
const res = await fetch(`${base}/v1/settle`, {
|
|
33748
|
+
method: "POST",
|
|
33749
|
+
headers: { "Content-Type": "application/json" },
|
|
33750
|
+
// The gateway accepts an empty body; only `limit` is recognised.
|
|
33751
|
+
// Always send a JSON body so the gateway's req.body shape parse
|
|
33752
|
+
// doesn't have to deal with an undefined.
|
|
33753
|
+
body: JSON.stringify(params ?? {})
|
|
33754
|
+
});
|
|
33755
|
+
if (!res.ok) {
|
|
33756
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33757
|
+
}
|
|
33758
|
+
return await res.json();
|
|
33438
33759
|
}
|
|
33439
33760
|
};
|
|
33440
33761
|
}
|
|
@@ -33458,7 +33779,7 @@ function genericPaymentDomain(chainId, escrowContract) {
|
|
|
33458
33779
|
verifyingContract: escrowContract
|
|
33459
33780
|
};
|
|
33460
33781
|
}
|
|
33461
|
-
var
|
|
33782
|
+
var ESCROW_DEPOSIT_ABI2 = [
|
|
33462
33783
|
{
|
|
33463
33784
|
type: "function",
|
|
33464
33785
|
name: "depositNative",
|
|
@@ -33615,6 +33936,7 @@ async function parsePSError(response) {
|
|
|
33615
33936
|
}
|
|
33616
33937
|
export {
|
|
33617
33938
|
ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
|
|
33939
|
+
ADD_DATA_TYPES,
|
|
33618
33940
|
AccountPersonalServerLiteOwnerBindingError,
|
|
33619
33941
|
AccountPersonalServerRegistrationError,
|
|
33620
33942
|
BUILDER_REGISTRATION_TYPES,
|
|
@@ -33624,13 +33946,14 @@ export {
|
|
|
33624
33946
|
CallbackStorage,
|
|
33625
33947
|
ContractFactory,
|
|
33626
33948
|
ContractNotFoundError,
|
|
33949
|
+
DATA_REGISTRY_STATUS_ABI,
|
|
33627
33950
|
DataFileEnvelopeSchema,
|
|
33951
|
+
DataPointStatus,
|
|
33628
33952
|
DropboxStorage,
|
|
33629
33953
|
ECIESError,
|
|
33630
|
-
ESCROW_DEPOSIT_ABI,
|
|
33954
|
+
ESCROW_DEPOSIT_ABI2 as ESCROW_DEPOSIT_ABI,
|
|
33631
33955
|
ExpiredTokenError,
|
|
33632
|
-
|
|
33633
|
-
FILE_REGISTRATION_TYPES,
|
|
33956
|
+
FEE_REGISTRY_ABI,
|
|
33634
33957
|
GENERIC_PAYMENT_TYPES,
|
|
33635
33958
|
GRANT_REGISTRATION_TYPES,
|
|
33636
33959
|
GRANT_REVOCATION_TYPES,
|
|
@@ -33643,6 +33966,7 @@ export {
|
|
|
33643
33966
|
MASTER_KEY_MESSAGE,
|
|
33644
33967
|
MissingAuthError,
|
|
33645
33968
|
NATIVE_ASSET_ADDRESS,
|
|
33969
|
+
NATIVE_VANA_ASSET,
|
|
33646
33970
|
NetworkError,
|
|
33647
33971
|
NodeECIESUint8Provider as NodeECIESProvider,
|
|
33648
33972
|
NodePlatformAdapter,
|
|
@@ -33660,6 +33984,8 @@ export {
|
|
|
33660
33984
|
PersonalServerError,
|
|
33661
33985
|
PinataStorage,
|
|
33662
33986
|
R2Storage,
|
|
33987
|
+
RECORD_DATA_ACCESS_TYPES,
|
|
33988
|
+
REGISTRATION_KIND_FOR_OP,
|
|
33663
33989
|
ReadOnlyError,
|
|
33664
33990
|
RelayerError,
|
|
33665
33991
|
SERVER_REGISTRATION_TYPES,
|
|
@@ -33674,10 +34000,15 @@ export {
|
|
|
33674
34000
|
VanaError,
|
|
33675
34001
|
VanaStorage,
|
|
33676
34002
|
assertValidPkceVerifier,
|
|
34003
|
+
buildDepositNativeRequest,
|
|
34004
|
+
buildDepositTokenRequest,
|
|
34005
|
+
buildMarkDataPointUnavailableRequest,
|
|
34006
|
+
buildPersonalServerDataReadRequest,
|
|
33677
34007
|
buildPersonalServerLiteOwnerBindingMessage,
|
|
33678
34008
|
buildPersonalServerLiteOwnerBindingSignature,
|
|
33679
34009
|
buildPersonalServerRegistrationSignature,
|
|
33680
34010
|
buildPersonalServerRegistrationTypedData,
|
|
34011
|
+
buildSetDataPointStatusRequest,
|
|
33681
34012
|
buildWeb3SignedHeader,
|
|
33682
34013
|
builderRegistrationDomain,
|
|
33683
34014
|
chains,
|
|
@@ -33696,14 +34027,19 @@ export {
|
|
|
33696
34027
|
createVanaStorageProvider,
|
|
33697
34028
|
createViemPersonalServerLiteOwnerBindingSigner,
|
|
33698
34029
|
createViemPersonalServerRegistrationSigner,
|
|
34030
|
+
dataRegistryContractAddress,
|
|
34031
|
+
dataRegistryDomain,
|
|
33699
34032
|
decryptWithPassword,
|
|
33700
34033
|
deriveMasterKey,
|
|
33701
34034
|
deriveScopeKey,
|
|
33702
34035
|
deserializeECIES,
|
|
33703
34036
|
detectPlatform,
|
|
34037
|
+
encodeDepositNativeData,
|
|
34038
|
+
encodeDepositTokenData,
|
|
34039
|
+
encodeSetDataPointStatusData,
|
|
33704
34040
|
encryptWithPassword,
|
|
33705
|
-
|
|
33706
|
-
|
|
34041
|
+
escrowContractAddress,
|
|
34042
|
+
escrowPaymentDomain,
|
|
33707
34043
|
generatePkceVerifier,
|
|
33708
34044
|
genericPaymentDomain,
|
|
33709
34045
|
getAbi,
|
|
@@ -33712,6 +34048,8 @@ export {
|
|
|
33712
34048
|
getContractAddress,
|
|
33713
34049
|
getContractController,
|
|
33714
34050
|
getContractInfo,
|
|
34051
|
+
getFee,
|
|
34052
|
+
getOpFee,
|
|
33715
34053
|
getPlatformCapabilities,
|
|
33716
34054
|
getServiceEndpoints,
|
|
33717
34055
|
grantRegistrationDomain,
|
|
@@ -33723,11 +34061,12 @@ export {
|
|
|
33723
34061
|
moksha,
|
|
33724
34062
|
mokshaServices,
|
|
33725
34063
|
mokshaTestnet2 as mokshaTestnet,
|
|
33726
|
-
parseGrantRegistrationPayload,
|
|
33727
34064
|
parsePSError,
|
|
33728
34065
|
parseScope,
|
|
33729
34066
|
parseWeb3SignedHeader,
|
|
34067
|
+
personalServerDataReadPath,
|
|
33730
34068
|
personalServerRegistrationDomain,
|
|
34069
|
+
readPersonalServerData,
|
|
33731
34070
|
recoverServerOwner,
|
|
33732
34071
|
registerPersonalServerSignature,
|
|
33733
34072
|
scopeCoveredByGrant,
|