@opendatalabs/vana-sdk 3.5.1 → 3.6.0
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 +438 -157
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +461 -162
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +7 -3
- package/dist/index.node.js +438 -157
- 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/package.json +20 -1
package/dist/index.node.cjs
CHANGED
|
@@ -1174,6 +1174,7 @@ var init_browser2 = __esm({
|
|
|
1174
1174
|
var index_node_exports = {};
|
|
1175
1175
|
__export(index_node_exports, {
|
|
1176
1176
|
ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT: () => ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
|
|
1177
|
+
ADD_DATA_TYPES: () => ADD_DATA_TYPES,
|
|
1177
1178
|
AccountPersonalServerLiteOwnerBindingError: () => AccountPersonalServerLiteOwnerBindingError,
|
|
1178
1179
|
AccountPersonalServerRegistrationError: () => AccountPersonalServerRegistrationError,
|
|
1179
1180
|
BUILDER_REGISTRATION_TYPES: () => BUILDER_REGISTRATION_TYPES,
|
|
@@ -1183,13 +1184,14 @@ __export(index_node_exports, {
|
|
|
1183
1184
|
CallbackStorage: () => CallbackStorage,
|
|
1184
1185
|
ContractFactory: () => ContractFactory,
|
|
1185
1186
|
ContractNotFoundError: () => ContractNotFoundError,
|
|
1187
|
+
DATA_REGISTRY_STATUS_ABI: () => DATA_REGISTRY_STATUS_ABI,
|
|
1186
1188
|
DataFileEnvelopeSchema: () => DataFileEnvelopeSchema,
|
|
1189
|
+
DataPointStatus: () => DataPointStatus,
|
|
1187
1190
|
DropboxStorage: () => DropboxStorage,
|
|
1188
1191
|
ECIESError: () => ECIESError,
|
|
1189
|
-
ESCROW_DEPOSIT_ABI: () =>
|
|
1192
|
+
ESCROW_DEPOSIT_ABI: () => ESCROW_DEPOSIT_ABI2,
|
|
1190
1193
|
ExpiredTokenError: () => ExpiredTokenError,
|
|
1191
|
-
|
|
1192
|
-
FILE_REGISTRATION_TYPES: () => FILE_REGISTRATION_TYPES,
|
|
1194
|
+
FEE_REGISTRY_ABI: () => FEE_REGISTRY_ABI,
|
|
1193
1195
|
GENERIC_PAYMENT_TYPES: () => GENERIC_PAYMENT_TYPES,
|
|
1194
1196
|
GRANT_REGISTRATION_TYPES: () => GRANT_REGISTRATION_TYPES,
|
|
1195
1197
|
GRANT_REVOCATION_TYPES: () => GRANT_REVOCATION_TYPES,
|
|
@@ -1202,6 +1204,7 @@ __export(index_node_exports, {
|
|
|
1202
1204
|
MASTER_KEY_MESSAGE: () => MASTER_KEY_MESSAGE,
|
|
1203
1205
|
MissingAuthError: () => MissingAuthError,
|
|
1204
1206
|
NATIVE_ASSET_ADDRESS: () => NATIVE_ASSET_ADDRESS,
|
|
1207
|
+
NATIVE_VANA_ASSET: () => NATIVE_VANA_ASSET,
|
|
1205
1208
|
NetworkError: () => NetworkError,
|
|
1206
1209
|
NodeECIESProvider: () => NodeECIESUint8Provider,
|
|
1207
1210
|
NodePlatformAdapter: () => NodePlatformAdapter,
|
|
@@ -1219,6 +1222,8 @@ __export(index_node_exports, {
|
|
|
1219
1222
|
PersonalServerError: () => PersonalServerError,
|
|
1220
1223
|
PinataStorage: () => PinataStorage,
|
|
1221
1224
|
R2Storage: () => R2Storage,
|
|
1225
|
+
RECORD_DATA_ACCESS_TYPES: () => RECORD_DATA_ACCESS_TYPES,
|
|
1226
|
+
REGISTRATION_KIND_FOR_OP: () => REGISTRATION_KIND_FOR_OP,
|
|
1222
1227
|
ReadOnlyError: () => ReadOnlyError,
|
|
1223
1228
|
RelayerError: () => RelayerError,
|
|
1224
1229
|
SERVER_REGISTRATION_TYPES: () => SERVER_REGISTRATION_TYPES,
|
|
@@ -1233,10 +1238,15 @@ __export(index_node_exports, {
|
|
|
1233
1238
|
VanaError: () => VanaError,
|
|
1234
1239
|
VanaStorage: () => VanaStorage,
|
|
1235
1240
|
assertValidPkceVerifier: () => assertValidPkceVerifier,
|
|
1241
|
+
buildDepositNativeRequest: () => buildDepositNativeRequest,
|
|
1242
|
+
buildDepositTokenRequest: () => buildDepositTokenRequest,
|
|
1243
|
+
buildMarkDataPointUnavailableRequest: () => buildMarkDataPointUnavailableRequest,
|
|
1244
|
+
buildPersonalServerDataReadRequest: () => buildPersonalServerDataReadRequest,
|
|
1236
1245
|
buildPersonalServerLiteOwnerBindingMessage: () => buildPersonalServerLiteOwnerBindingMessage,
|
|
1237
1246
|
buildPersonalServerLiteOwnerBindingSignature: () => buildPersonalServerLiteOwnerBindingSignature,
|
|
1238
1247
|
buildPersonalServerRegistrationSignature: () => buildPersonalServerRegistrationSignature,
|
|
1239
1248
|
buildPersonalServerRegistrationTypedData: () => buildPersonalServerRegistrationTypedData,
|
|
1249
|
+
buildSetDataPointStatusRequest: () => buildSetDataPointStatusRequest,
|
|
1240
1250
|
buildWeb3SignedHeader: () => buildWeb3SignedHeader,
|
|
1241
1251
|
builderRegistrationDomain: () => builderRegistrationDomain,
|
|
1242
1252
|
chains: () => chains,
|
|
@@ -1255,14 +1265,19 @@ __export(index_node_exports, {
|
|
|
1255
1265
|
createVanaStorageProvider: () => createVanaStorageProvider,
|
|
1256
1266
|
createViemPersonalServerLiteOwnerBindingSigner: () => createViemPersonalServerLiteOwnerBindingSigner,
|
|
1257
1267
|
createViemPersonalServerRegistrationSigner: () => createViemPersonalServerRegistrationSigner,
|
|
1268
|
+
dataRegistryContractAddress: () => dataRegistryContractAddress,
|
|
1269
|
+
dataRegistryDomain: () => dataRegistryDomain,
|
|
1258
1270
|
decryptWithPassword: () => decryptWithPassword,
|
|
1259
1271
|
deriveMasterKey: () => deriveMasterKey,
|
|
1260
1272
|
deriveScopeKey: () => deriveScopeKey,
|
|
1261
1273
|
deserializeECIES: () => deserializeECIES,
|
|
1262
1274
|
detectPlatform: () => detectPlatform,
|
|
1275
|
+
encodeDepositNativeData: () => encodeDepositNativeData,
|
|
1276
|
+
encodeDepositTokenData: () => encodeDepositTokenData,
|
|
1277
|
+
encodeSetDataPointStatusData: () => encodeSetDataPointStatusData,
|
|
1263
1278
|
encryptWithPassword: () => encryptWithPassword,
|
|
1264
|
-
|
|
1265
|
-
|
|
1279
|
+
escrowContractAddress: () => escrowContractAddress,
|
|
1280
|
+
escrowPaymentDomain: () => escrowPaymentDomain,
|
|
1266
1281
|
generatePkceVerifier: () => generatePkceVerifier,
|
|
1267
1282
|
genericPaymentDomain: () => genericPaymentDomain,
|
|
1268
1283
|
getAbi: () => getAbi,
|
|
@@ -1271,6 +1286,8 @@ __export(index_node_exports, {
|
|
|
1271
1286
|
getContractAddress: () => getContractAddress,
|
|
1272
1287
|
getContractController: () => getContractController,
|
|
1273
1288
|
getContractInfo: () => getContractInfo,
|
|
1289
|
+
getFee: () => getFee,
|
|
1290
|
+
getOpFee: () => getOpFee,
|
|
1274
1291
|
getPlatformCapabilities: () => getPlatformCapabilities,
|
|
1275
1292
|
getServiceEndpoints: () => getServiceEndpoints,
|
|
1276
1293
|
grantRegistrationDomain: () => grantRegistrationDomain,
|
|
@@ -1282,11 +1299,12 @@ __export(index_node_exports, {
|
|
|
1282
1299
|
moksha: () => moksha,
|
|
1283
1300
|
mokshaServices: () => mokshaServices,
|
|
1284
1301
|
mokshaTestnet: () => mokshaTestnet2,
|
|
1285
|
-
parseGrantRegistrationPayload: () => parseGrantRegistrationPayload,
|
|
1286
1302
|
parsePSError: () => parsePSError,
|
|
1287
1303
|
parseScope: () => parseScope,
|
|
1288
1304
|
parseWeb3SignedHeader: () => parseWeb3SignedHeader,
|
|
1305
|
+
personalServerDataReadPath: () => personalServerDataReadPath,
|
|
1289
1306
|
personalServerRegistrationDomain: () => personalServerRegistrationDomain,
|
|
1307
|
+
readPersonalServerData: () => readPersonalServerData,
|
|
1290
1308
|
recoverServerOwner: () => recoverServerOwner,
|
|
1291
1309
|
registerPersonalServerSignature: () => registerPersonalServerSignature,
|
|
1292
1310
|
scopeCoveredByGrant: () => scopeCoveredByGrant,
|
|
@@ -32712,6 +32730,7 @@ function formatOAuthError(body, status) {
|
|
|
32712
32730
|
// src/protocol/eip712.ts
|
|
32713
32731
|
var DOMAIN_NAME = "Vana Data Portability";
|
|
32714
32732
|
var DOMAIN_VERSION = "1";
|
|
32733
|
+
var NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
|
|
32715
32734
|
function buildDomain(chainId, verifyingContract) {
|
|
32716
32735
|
return {
|
|
32717
32736
|
name: DOMAIN_NAME,
|
|
@@ -32720,13 +32739,7 @@ function buildDomain(chainId, verifyingContract) {
|
|
|
32720
32739
|
verifyingContract
|
|
32721
32740
|
};
|
|
32722
32741
|
}
|
|
32723
|
-
function
|
|
32724
|
-
return buildDomain(
|
|
32725
|
-
config.chainId,
|
|
32726
|
-
config.contracts.dataRegistry
|
|
32727
|
-
);
|
|
32728
|
-
}
|
|
32729
|
-
function fileDeletionDomain(config) {
|
|
32742
|
+
function dataRegistryDomain(config) {
|
|
32730
32743
|
return buildDomain(
|
|
32731
32744
|
config.chainId,
|
|
32732
32745
|
config.contracts.dataRegistry
|
|
@@ -32756,31 +32769,26 @@ function builderRegistrationDomain(config) {
|
|
|
32756
32769
|
config.contracts.dataPortabilityGrantees
|
|
32757
32770
|
);
|
|
32758
32771
|
}
|
|
32759
|
-
|
|
32760
|
-
|
|
32761
|
-
|
|
32762
|
-
|
|
32763
|
-
|
|
32764
|
-
|
|
32765
|
-
};
|
|
32766
|
-
var FILE_DELETION_TYPES = {
|
|
32767
|
-
FileDeletion: [
|
|
32768
|
-
{ name: "ownerAddress", type: "address" },
|
|
32769
|
-
{ name: "fileId", type: "bytes32" }
|
|
32770
|
-
]
|
|
32771
|
-
};
|
|
32772
|
+
function escrowPaymentDomain(config) {
|
|
32773
|
+
return buildDomain(
|
|
32774
|
+
config.chainId,
|
|
32775
|
+
config.contracts.dataPortabilityEscrow
|
|
32776
|
+
);
|
|
32777
|
+
}
|
|
32772
32778
|
var GRANT_REGISTRATION_TYPES = {
|
|
32773
32779
|
GrantRegistration: [
|
|
32774
32780
|
{ name: "grantorAddress", type: "address" },
|
|
32775
32781
|
{ name: "granteeId", type: "bytes32" },
|
|
32776
|
-
{ name: "
|
|
32777
|
-
{ name: "
|
|
32782
|
+
{ name: "scopes", type: "string[]" },
|
|
32783
|
+
{ name: "grantVersion", type: "uint256" },
|
|
32784
|
+
{ name: "expiresAt", type: "uint256" }
|
|
32778
32785
|
]
|
|
32779
32786
|
};
|
|
32780
32787
|
var GRANT_REVOCATION_TYPES = {
|
|
32781
32788
|
GrantRevocation: [
|
|
32782
32789
|
{ name: "grantorAddress", type: "address" },
|
|
32783
|
-
{ name: "grantId", type: "bytes32" }
|
|
32790
|
+
{ name: "grantId", type: "bytes32" },
|
|
32791
|
+
{ name: "grantVersion", type: "uint256" }
|
|
32784
32792
|
]
|
|
32785
32793
|
};
|
|
32786
32794
|
var SERVER_REGISTRATION_TYPES = {
|
|
@@ -32799,6 +32807,24 @@ var BUILDER_REGISTRATION_TYPES = {
|
|
|
32799
32807
|
{ name: "appUrl", type: "string" }
|
|
32800
32808
|
]
|
|
32801
32809
|
};
|
|
32810
|
+
var ADD_DATA_TYPES = {
|
|
32811
|
+
AddData: [
|
|
32812
|
+
{ name: "ownerAddress", type: "address" },
|
|
32813
|
+
{ name: "scope", type: "string" },
|
|
32814
|
+
{ name: "dataHash", type: "bytes32" },
|
|
32815
|
+
{ name: "metadataHash", type: "bytes32" },
|
|
32816
|
+
{ name: "expectedVersion", type: "uint256" }
|
|
32817
|
+
]
|
|
32818
|
+
};
|
|
32819
|
+
var RECORD_DATA_ACCESS_TYPES = {
|
|
32820
|
+
RecordDataAccess: [
|
|
32821
|
+
{ name: "ownerAddress", type: "address" },
|
|
32822
|
+
{ name: "scope", type: "string" },
|
|
32823
|
+
{ name: "version", type: "uint256" },
|
|
32824
|
+
{ name: "accessor", type: "address" },
|
|
32825
|
+
{ name: "recordId", type: "bytes32" }
|
|
32826
|
+
]
|
|
32827
|
+
};
|
|
32802
32828
|
|
|
32803
32829
|
// src/protocol/personal-server-registration.ts
|
|
32804
32830
|
var import_viem14 = require("viem");
|
|
@@ -33246,67 +33272,34 @@ function isDataPortabilityGatewayConfig(value) {
|
|
|
33246
33272
|
return false;
|
|
33247
33273
|
}
|
|
33248
33274
|
const c = contracts;
|
|
33249
|
-
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]);
|
|
33250
|
-
}
|
|
33251
|
-
function parseGrantRegistrationPayload(grant) {
|
|
33252
|
-
let parsed;
|
|
33253
|
-
try {
|
|
33254
|
-
parsed = JSON.parse(grant);
|
|
33255
|
-
} catch {
|
|
33256
|
-
return null;
|
|
33257
|
-
}
|
|
33258
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
33259
|
-
return null;
|
|
33260
|
-
}
|
|
33261
|
-
const value = parsed;
|
|
33262
|
-
if (!Array.isArray(value["scopes"]) || value["scopes"].length === 0) {
|
|
33263
|
-
return null;
|
|
33264
|
-
}
|
|
33265
|
-
if (!value["scopes"].every((scope) => typeof scope === "string")) {
|
|
33266
|
-
return null;
|
|
33267
|
-
}
|
|
33268
|
-
if (typeof value["expiresAt"] !== "number" || !Number.isFinite(value["expiresAt"])) {
|
|
33269
|
-
return null;
|
|
33270
|
-
}
|
|
33271
|
-
if (value["user"] !== void 0 && !isHexString(value["user"])) {
|
|
33272
|
-
return null;
|
|
33273
|
-
}
|
|
33274
|
-
if (value["builder"] !== void 0 && !isHexString(value["builder"])) {
|
|
33275
|
-
return null;
|
|
33276
|
-
}
|
|
33277
|
-
if (value["nonce"] !== void 0 && (typeof value["nonce"] !== "number" || !Number.isFinite(value["nonce"]))) {
|
|
33278
|
-
return null;
|
|
33279
|
-
}
|
|
33280
|
-
return {
|
|
33281
|
-
user: value["user"],
|
|
33282
|
-
builder: value["builder"],
|
|
33283
|
-
scopes: value["scopes"],
|
|
33284
|
-
expiresAt: value["expiresAt"],
|
|
33285
|
-
nonce: value["nonce"]
|
|
33286
|
-
};
|
|
33275
|
+
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]) && isHexString(c["dataPortabilityEscrow"]) && isHexString(c["feeRegistry"]);
|
|
33287
33276
|
}
|
|
33288
|
-
function
|
|
33277
|
+
function toUint256(value) {
|
|
33289
33278
|
try {
|
|
33290
|
-
|
|
33291
|
-
|
|
33292
|
-
|
|
33293
|
-
|
|
33294
|
-
|
|
33279
|
+
if (typeof value === "number" && !Number.isSafeInteger(value)) {
|
|
33280
|
+
return null;
|
|
33281
|
+
}
|
|
33282
|
+
const big = typeof value === "bigint" ? value : BigInt(value);
|
|
33283
|
+
if (big < 0n) return null;
|
|
33284
|
+
return big;
|
|
33295
33285
|
} catch {
|
|
33296
33286
|
return null;
|
|
33297
33287
|
}
|
|
33298
33288
|
}
|
|
33299
33289
|
async function verifyGrantRegistration(input) {
|
|
33300
|
-
|
|
33301
|
-
|
|
33302
|
-
|
|
33303
|
-
|
|
33304
|
-
|
|
33305
|
-
};
|
|
33290
|
+
if (!Array.isArray(input.scopes) || input.scopes.length === 0) {
|
|
33291
|
+
return { valid: false, error: "scopes must be a non-empty array" };
|
|
33292
|
+
}
|
|
33293
|
+
if (!input.scopes.every((scope) => typeof scope === "string")) {
|
|
33294
|
+
return { valid: false, error: "scopes must contain only strings" };
|
|
33306
33295
|
}
|
|
33307
|
-
const
|
|
33308
|
-
if (
|
|
33309
|
-
return { valid: false, error: "
|
|
33296
|
+
const grantVersion = toUint256(input.grantVersion);
|
|
33297
|
+
if (grantVersion === null || grantVersion < 1n) {
|
|
33298
|
+
return { valid: false, error: "grantVersion must be a uint256 >= 1" };
|
|
33299
|
+
}
|
|
33300
|
+
const expiresAt = toUint256(input.expiresAt);
|
|
33301
|
+
if (expiresAt === null) {
|
|
33302
|
+
return { valid: false, error: "expiresAt must be a non-negative uint256" };
|
|
33310
33303
|
}
|
|
33311
33304
|
let valid;
|
|
33312
33305
|
try {
|
|
@@ -33318,8 +33311,9 @@ async function verifyGrantRegistration(input) {
|
|
|
33318
33311
|
message: {
|
|
33319
33312
|
grantorAddress: input.grantorAddress,
|
|
33320
33313
|
granteeId: input.granteeId,
|
|
33321
|
-
|
|
33322
|
-
|
|
33314
|
+
scopes: input.scopes,
|
|
33315
|
+
grantVersion,
|
|
33316
|
+
expiresAt
|
|
33323
33317
|
},
|
|
33324
33318
|
signature: input.signature
|
|
33325
33319
|
});
|
|
@@ -33330,26 +33324,269 @@ async function verifyGrantRegistration(input) {
|
|
|
33330
33324
|
return { valid: false, error: "Grant signature does not match grantor" };
|
|
33331
33325
|
}
|
|
33332
33326
|
const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
|
|
33333
|
-
if (
|
|
33327
|
+
if (expiresAt > 0n && expiresAt < BigInt(nowSeconds)) {
|
|
33334
33328
|
return { valid: false, error: "Grant has expired" };
|
|
33335
33329
|
}
|
|
33336
|
-
if (payload.user !== void 0 && payload.user.toLowerCase() !== input.grantorAddress.toLowerCase()) {
|
|
33337
|
-
return { valid: false, error: "Grant user does not match grantorAddress" };
|
|
33338
|
-
}
|
|
33339
33330
|
return {
|
|
33340
33331
|
valid: true,
|
|
33341
33332
|
grantorAddress: input.grantorAddress,
|
|
33342
33333
|
granteeId: input.granteeId,
|
|
33343
|
-
|
|
33344
|
-
|
|
33345
|
-
|
|
33334
|
+
scopes: input.scopes,
|
|
33335
|
+
grantVersion: grantVersion.toString(),
|
|
33336
|
+
expiresAt: expiresAt.toString()
|
|
33346
33337
|
};
|
|
33347
33338
|
}
|
|
33348
33339
|
|
|
33349
|
-
// src/protocol/
|
|
33340
|
+
// src/protocol/fee-registry.ts
|
|
33341
|
+
var import_viem18 = require("viem");
|
|
33342
|
+
var FEE_REGISTRY_ABI = (0, import_viem18.parseAbi)([
|
|
33343
|
+
"struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
|
|
33344
|
+
"function fees(bytes32 operation) view returns (Fee)",
|
|
33345
|
+
"function operationKey(string name) pure returns (bytes32)"
|
|
33346
|
+
]);
|
|
33347
|
+
var REGISTRATION_KIND_FOR_OP = {
|
|
33348
|
+
grant: "grant_registration",
|
|
33349
|
+
data: "data_registration",
|
|
33350
|
+
server: "server_registration",
|
|
33351
|
+
builder: "builder_registration"
|
|
33352
|
+
};
|
|
33353
|
+
function operationNameFor(kind, opts) {
|
|
33354
|
+
switch (kind) {
|
|
33355
|
+
case "grant_registration":
|
|
33356
|
+
return opts?.grantRegistrationOpName ?? "grant_registration";
|
|
33357
|
+
case "data_access":
|
|
33358
|
+
return opts?.dataAccessOpName ?? "data_access";
|
|
33359
|
+
case "data_registration":
|
|
33360
|
+
return opts?.dataRegistrationOpName ?? "data_registration";
|
|
33361
|
+
case "server_registration":
|
|
33362
|
+
return opts?.serverRegistrationOpName ?? "server_registration";
|
|
33363
|
+
case "builder_registration":
|
|
33364
|
+
return opts?.builderRegistrationOpName ?? "builder_registration";
|
|
33365
|
+
}
|
|
33366
|
+
}
|
|
33367
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
33368
|
+
async function getFee(client, config, kind, opts) {
|
|
33369
|
+
const address = config.contracts.feeRegistry;
|
|
33370
|
+
const opName = operationNameFor(kind, opts);
|
|
33371
|
+
const opKey = await client.readContract({
|
|
33372
|
+
address,
|
|
33373
|
+
abi: FEE_REGISTRY_ABI,
|
|
33374
|
+
functionName: "operationKey",
|
|
33375
|
+
args: [opName]
|
|
33376
|
+
});
|
|
33377
|
+
const fee = await client.readContract({
|
|
33378
|
+
address,
|
|
33379
|
+
abi: FEE_REGISTRY_ABI,
|
|
33380
|
+
functionName: "fees",
|
|
33381
|
+
args: [opKey]
|
|
33382
|
+
});
|
|
33383
|
+
if (fee.enabled && fee.payee === ZERO_ADDRESS) {
|
|
33384
|
+
throw new Error(
|
|
33385
|
+
`FeeRegistry: enabled operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
|
|
33386
|
+
);
|
|
33387
|
+
}
|
|
33388
|
+
return fee;
|
|
33389
|
+
}
|
|
33390
|
+
async function getOpFee(client, config, opType, opts) {
|
|
33391
|
+
const registrationKind = REGISTRATION_KIND_FOR_OP[opType];
|
|
33392
|
+
if (!registrationKind) {
|
|
33393
|
+
throw new Error(
|
|
33394
|
+
`getOpFee: unknown opType "${opType}" \u2014 supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(", ")}`
|
|
33395
|
+
);
|
|
33396
|
+
}
|
|
33397
|
+
const includeDataAccess = opType === "grant";
|
|
33398
|
+
const [registration, dataAccess] = await Promise.all([
|
|
33399
|
+
getFee(client, config, registrationKind, opts),
|
|
33400
|
+
includeDataAccess ? getFee(client, config, "data_access", opts) : Promise.resolve({
|
|
33401
|
+
amount: 0n,
|
|
33402
|
+
asset: ZERO_ADDRESS,
|
|
33403
|
+
payee: ZERO_ADDRESS,
|
|
33404
|
+
enabled: false
|
|
33405
|
+
})
|
|
33406
|
+
]);
|
|
33407
|
+
if (registration.enabled && dataAccess.enabled && registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
|
|
33408
|
+
throw new Error(
|
|
33409
|
+
`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.`
|
|
33410
|
+
);
|
|
33411
|
+
}
|
|
33412
|
+
const asset = registration.enabled ? registration.asset : dataAccess.enabled ? dataAccess.asset : ZERO_ADDRESS;
|
|
33413
|
+
return {
|
|
33414
|
+
asset,
|
|
33415
|
+
registrationFee: registration.enabled ? registration.amount : 0n,
|
|
33416
|
+
dataAccessFee: dataAccess.enabled ? dataAccess.amount : 0n,
|
|
33417
|
+
registrationEnabled: registration.enabled,
|
|
33418
|
+
dataAccessEnabled: dataAccess.enabled,
|
|
33419
|
+
registrationPayee: registration.enabled ? registration.payee : ZERO_ADDRESS,
|
|
33420
|
+
dataAccessPayee: dataAccess.enabled ? dataAccess.payee : ZERO_ADDRESS
|
|
33421
|
+
};
|
|
33422
|
+
}
|
|
33423
|
+
|
|
33424
|
+
// src/protocol/escrow-deposit.ts
|
|
33425
|
+
var import_viem19 = require("viem");
|
|
33426
|
+
var ESCROW_DEPOSIT_ABI = [
|
|
33427
|
+
{
|
|
33428
|
+
type: "function",
|
|
33429
|
+
name: "depositNative",
|
|
33430
|
+
stateMutability: "payable",
|
|
33431
|
+
inputs: [{ name: "account", type: "address" }],
|
|
33432
|
+
outputs: []
|
|
33433
|
+
},
|
|
33434
|
+
{
|
|
33435
|
+
type: "function",
|
|
33436
|
+
name: "depositToken",
|
|
33437
|
+
stateMutability: "nonpayable",
|
|
33438
|
+
inputs: [
|
|
33439
|
+
{ name: "account", type: "address" },
|
|
33440
|
+
{ name: "token", type: "address" },
|
|
33441
|
+
{ name: "amount", type: "uint256" }
|
|
33442
|
+
],
|
|
33443
|
+
outputs: []
|
|
33444
|
+
}
|
|
33445
|
+
];
|
|
33446
|
+
function escrowContractAddress(config) {
|
|
33447
|
+
return config.contracts.dataPortabilityEscrow;
|
|
33448
|
+
}
|
|
33449
|
+
function encodeDepositNativeData(input) {
|
|
33450
|
+
return (0, import_viem19.encodeFunctionData)({
|
|
33451
|
+
abi: ESCROW_DEPOSIT_ABI,
|
|
33452
|
+
functionName: "depositNative",
|
|
33453
|
+
args: [input.account]
|
|
33454
|
+
});
|
|
33455
|
+
}
|
|
33456
|
+
function encodeDepositTokenData(input) {
|
|
33457
|
+
return (0, import_viem19.encodeFunctionData)({
|
|
33458
|
+
abi: ESCROW_DEPOSIT_ABI,
|
|
33459
|
+
functionName: "depositToken",
|
|
33460
|
+
args: [input.account, input.token, input.amount]
|
|
33461
|
+
});
|
|
33462
|
+
}
|
|
33463
|
+
function buildDepositNativeRequest(config, input) {
|
|
33464
|
+
return {
|
|
33465
|
+
to: escrowContractAddress(config),
|
|
33466
|
+
data: encodeDepositNativeData({ account: input.account }),
|
|
33467
|
+
value: input.amount
|
|
33468
|
+
};
|
|
33469
|
+
}
|
|
33470
|
+
function buildDepositTokenRequest(config, input) {
|
|
33471
|
+
return {
|
|
33472
|
+
to: escrowContractAddress(config),
|
|
33473
|
+
data: encodeDepositTokenData(input)
|
|
33474
|
+
};
|
|
33475
|
+
}
|
|
33476
|
+
|
|
33477
|
+
// src/protocol/data-point-status.ts
|
|
33478
|
+
var import_viem20 = require("viem");
|
|
33479
|
+
var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
|
|
33480
|
+
DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
|
|
33481
|
+
DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
|
|
33482
|
+
DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
|
|
33483
|
+
DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
|
|
33484
|
+
return DataPointStatus2;
|
|
33485
|
+
})(DataPointStatus || {});
|
|
33486
|
+
var DATA_REGISTRY_STATUS_ABI = [
|
|
33487
|
+
{
|
|
33488
|
+
type: "function",
|
|
33489
|
+
name: "setStatus",
|
|
33490
|
+
stateMutability: "nonpayable",
|
|
33491
|
+
inputs: [
|
|
33492
|
+
{ name: "scope", type: "string" },
|
|
33493
|
+
{ name: "newStatus", type: "uint8" }
|
|
33494
|
+
],
|
|
33495
|
+
outputs: []
|
|
33496
|
+
}
|
|
33497
|
+
];
|
|
33498
|
+
function dataRegistryContractAddress(config) {
|
|
33499
|
+
return config.contracts.dataRegistry;
|
|
33500
|
+
}
|
|
33501
|
+
function encodeSetDataPointStatusData(input) {
|
|
33502
|
+
return (0, import_viem20.encodeFunctionData)({
|
|
33503
|
+
abi: DATA_REGISTRY_STATUS_ABI,
|
|
33504
|
+
functionName: "setStatus",
|
|
33505
|
+
args: [input.scope, input.status]
|
|
33506
|
+
});
|
|
33507
|
+
}
|
|
33508
|
+
function buildSetDataPointStatusRequest(config, input) {
|
|
33509
|
+
return {
|
|
33510
|
+
to: dataRegistryContractAddress(config),
|
|
33511
|
+
data: encodeSetDataPointStatusData(input)
|
|
33512
|
+
};
|
|
33513
|
+
}
|
|
33514
|
+
function buildMarkDataPointUnavailableRequest(config, input) {
|
|
33515
|
+
return buildSetDataPointStatusRequest(config, {
|
|
33516
|
+
scope: input.scope,
|
|
33517
|
+
status: 3 /* Unavailable */
|
|
33518
|
+
});
|
|
33519
|
+
}
|
|
33520
|
+
|
|
33521
|
+
// src/protocol/data-file.ts
|
|
33350
33522
|
var import_zod = require("zod");
|
|
33523
|
+
var DataFileEnvelopeSchema = import_zod.z.object({
|
|
33524
|
+
$schema: import_zod.z.string().url().optional(),
|
|
33525
|
+
version: import_zod.z.literal("1.0"),
|
|
33526
|
+
scope: import_zod.z.string(),
|
|
33527
|
+
schemaId: import_zod.z.string().optional(),
|
|
33528
|
+
collectedAt: import_zod.z.string().datetime(),
|
|
33529
|
+
data: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown())
|
|
33530
|
+
});
|
|
33531
|
+
function createDataFileEnvelope(scope, collectedAt, data, schemaUrl, schemaId) {
|
|
33532
|
+
return {
|
|
33533
|
+
...schemaUrl !== void 0 && { $schema: schemaUrl },
|
|
33534
|
+
...schemaId !== void 0 && { schemaId },
|
|
33535
|
+
version: "1.0",
|
|
33536
|
+
scope,
|
|
33537
|
+
collectedAt,
|
|
33538
|
+
data
|
|
33539
|
+
};
|
|
33540
|
+
}
|
|
33541
|
+
var IngestResponseSchema = import_zod.z.object({
|
|
33542
|
+
scope: import_zod.z.string(),
|
|
33543
|
+
collectedAt: import_zod.z.string().datetime(),
|
|
33544
|
+
status: import_zod.z.enum(["stored", "syncing"])
|
|
33545
|
+
});
|
|
33546
|
+
|
|
33547
|
+
// src/protocol/personal-server-data.ts
|
|
33548
|
+
function personalServerDataReadPath(scope) {
|
|
33549
|
+
return `/v1/data/${encodeURIComponent(scope)}`;
|
|
33550
|
+
}
|
|
33551
|
+
async function buildPersonalServerDataReadRequest(params) {
|
|
33552
|
+
const path = personalServerDataReadPath(params.scope);
|
|
33553
|
+
const baseUrl = params.personalServerUrl.replace(/\/+$/, "");
|
|
33554
|
+
const audience = params.audience ?? baseUrl;
|
|
33555
|
+
const headers = new Headers(params.headers);
|
|
33556
|
+
headers.set(
|
|
33557
|
+
"Authorization",
|
|
33558
|
+
await buildWeb3SignedHeader({
|
|
33559
|
+
aud: audience,
|
|
33560
|
+
grantId: params.grantId,
|
|
33561
|
+
method: "GET",
|
|
33562
|
+
signMessage: params.signMessage,
|
|
33563
|
+
uri: path
|
|
33564
|
+
})
|
|
33565
|
+
);
|
|
33566
|
+
return new Request(`${baseUrl}${path}`, {
|
|
33567
|
+
headers,
|
|
33568
|
+
method: "GET"
|
|
33569
|
+
});
|
|
33570
|
+
}
|
|
33571
|
+
async function readPersonalServerData(params) {
|
|
33572
|
+
const fetchFn = params.fetch ?? globalThis.fetch;
|
|
33573
|
+
if (fetchFn === void 0) {
|
|
33574
|
+
throw new Error("No fetch implementation available");
|
|
33575
|
+
}
|
|
33576
|
+
const request = await buildPersonalServerDataReadRequest(params);
|
|
33577
|
+
const response = await fetchFn(request);
|
|
33578
|
+
if (!response.ok) {
|
|
33579
|
+
throw new Error(
|
|
33580
|
+
`Personal Server data read failed: ${response.status} ${response.statusText}`
|
|
33581
|
+
);
|
|
33582
|
+
}
|
|
33583
|
+
return DataFileEnvelopeSchema.parse(await response.json());
|
|
33584
|
+
}
|
|
33585
|
+
|
|
33586
|
+
// src/protocol/scopes.ts
|
|
33587
|
+
var import_zod2 = require("zod");
|
|
33351
33588
|
var SEGMENT_RE = /^[a-z0-9][a-z0-9_]*$/;
|
|
33352
|
-
var ScopeSchema =
|
|
33589
|
+
var ScopeSchema = import_zod2.z.string().refine(
|
|
33353
33590
|
(scope) => {
|
|
33354
33591
|
const parts = scope.split(".");
|
|
33355
33592
|
return parts.length >= 2 && parts.length <= 3 && parts.every((part) => SEGMENT_RE.test(part));
|
|
@@ -33390,32 +33627,6 @@ function scopeCoveredByGrant(requestedScope, grantedScopes) {
|
|
|
33390
33627
|
);
|
|
33391
33628
|
}
|
|
33392
33629
|
|
|
33393
|
-
// src/protocol/data-file.ts
|
|
33394
|
-
var import_zod2 = require("zod");
|
|
33395
|
-
var DataFileEnvelopeSchema = import_zod2.z.object({
|
|
33396
|
-
$schema: import_zod2.z.string().url().optional(),
|
|
33397
|
-
version: import_zod2.z.literal("1.0"),
|
|
33398
|
-
scope: import_zod2.z.string(),
|
|
33399
|
-
schemaId: import_zod2.z.string().optional(),
|
|
33400
|
-
collectedAt: import_zod2.z.string().datetime(),
|
|
33401
|
-
data: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown())
|
|
33402
|
-
});
|
|
33403
|
-
function createDataFileEnvelope(scope, collectedAt, data, schemaUrl, schemaId) {
|
|
33404
|
-
return {
|
|
33405
|
-
...schemaUrl !== void 0 && { $schema: schemaUrl },
|
|
33406
|
-
...schemaId !== void 0 && { schemaId },
|
|
33407
|
-
version: "1.0",
|
|
33408
|
-
scope,
|
|
33409
|
-
collectedAt,
|
|
33410
|
-
data
|
|
33411
|
-
};
|
|
33412
|
-
}
|
|
33413
|
-
var IngestResponseSchema = import_zod2.z.object({
|
|
33414
|
-
scope: import_zod2.z.string(),
|
|
33415
|
-
collectedAt: import_zod2.z.string().datetime(),
|
|
33416
|
-
status: import_zod2.z.enum(["stored", "syncing"])
|
|
33417
|
-
});
|
|
33418
|
-
|
|
33419
33630
|
// src/protocol/gateway.ts
|
|
33420
33631
|
function createGatewayClient(baseUrl) {
|
|
33421
33632
|
const base = baseUrl.replace(/\/+$/, "");
|
|
@@ -33423,16 +33634,6 @@ function createGatewayClient(baseUrl) {
|
|
|
33423
33634
|
const envelope = await res.json();
|
|
33424
33635
|
return envelope.data;
|
|
33425
33636
|
}
|
|
33426
|
-
function normalizeFileRecord(record) {
|
|
33427
|
-
return {
|
|
33428
|
-
fileId: record.fileId ?? record.id ?? "",
|
|
33429
|
-
owner: record.owner ?? record.ownerAddress ?? "",
|
|
33430
|
-
url: record.url,
|
|
33431
|
-
schemaId: record.schemaId,
|
|
33432
|
-
createdAt: record.createdAt ?? record.addedAt ?? "",
|
|
33433
|
-
deletedAt: record.deletedAt ?? null
|
|
33434
|
-
};
|
|
33435
|
-
}
|
|
33436
33637
|
function getMutationId(body, key) {
|
|
33437
33638
|
const value = body[key] ?? body["id"];
|
|
33438
33639
|
return typeof value === "string" ? value : void 0;
|
|
@@ -33482,31 +33683,33 @@ function createGatewayClient(baseUrl) {
|
|
|
33482
33683
|
}
|
|
33483
33684
|
return unwrapEnvelope(res);
|
|
33484
33685
|
},
|
|
33485
|
-
async
|
|
33486
|
-
const res = await fetch(`${base}/v1/
|
|
33686
|
+
async getDataPoint(dataPointId) {
|
|
33687
|
+
const res = await fetch(`${base}/v1/data/${dataPointId}`);
|
|
33487
33688
|
if (res.status === 404) return null;
|
|
33488
33689
|
if (!res.ok) {
|
|
33489
33690
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33490
33691
|
}
|
|
33491
|
-
return
|
|
33692
|
+
return unwrapEnvelope(res);
|
|
33492
33693
|
},
|
|
33493
|
-
async
|
|
33694
|
+
async listDataPointsByOwner(owner, cursor, options) {
|
|
33494
33695
|
const params = new URLSearchParams({ user: owner });
|
|
33495
33696
|
if (cursor !== null) {
|
|
33496
33697
|
params.set("cursor", cursor);
|
|
33497
33698
|
}
|
|
33498
|
-
if (options?.
|
|
33499
|
-
params.set("
|
|
33699
|
+
if (options?.since) {
|
|
33700
|
+
params.set("since", options.since);
|
|
33701
|
+
}
|
|
33702
|
+
if (options?.limit !== void 0) {
|
|
33703
|
+
params.set("limit", String(options.limit));
|
|
33500
33704
|
}
|
|
33501
|
-
const res = await fetch(`${base}/v1/
|
|
33705
|
+
const res = await fetch(`${base}/v1/data?${params.toString()}`);
|
|
33502
33706
|
if (!res.ok) {
|
|
33503
33707
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33504
33708
|
}
|
|
33505
33709
|
const envelope = await res.json();
|
|
33506
|
-
const
|
|
33507
|
-
const nextCursor = pagination?.hasMore === false ? null : pagination?.nextCursor ?? envelope.data.cursor ?? null;
|
|
33710
|
+
const nextCursor = envelope.pagination?.hasMore === false ? null : envelope.pagination?.nextCursor ?? null;
|
|
33508
33711
|
return {
|
|
33509
|
-
|
|
33712
|
+
dataPoints: envelope.data.dataPoints,
|
|
33510
33713
|
cursor: nextCursor
|
|
33511
33714
|
};
|
|
33512
33715
|
},
|
|
@@ -33548,8 +33751,8 @@ function createGatewayClient(baseUrl) {
|
|
|
33548
33751
|
alreadyRegistered: false
|
|
33549
33752
|
};
|
|
33550
33753
|
},
|
|
33551
|
-
async
|
|
33552
|
-
const res = await fetch(`${base}/v1/
|
|
33754
|
+
async registerBuilder(params) {
|
|
33755
|
+
const res = await fetch(`${base}/v1/builders`, {
|
|
33553
33756
|
method: "POST",
|
|
33554
33757
|
headers: {
|
|
33555
33758
|
"Content-Type": "application/json",
|
|
@@ -33557,22 +33760,57 @@ function createGatewayClient(baseUrl) {
|
|
|
33557
33760
|
},
|
|
33558
33761
|
body: JSON.stringify({
|
|
33559
33762
|
ownerAddress: params.ownerAddress,
|
|
33560
|
-
|
|
33561
|
-
|
|
33763
|
+
granteeAddress: params.granteeAddress,
|
|
33764
|
+
publicKey: params.publicKey,
|
|
33765
|
+
appUrl: params.appUrl
|
|
33562
33766
|
})
|
|
33563
33767
|
});
|
|
33564
33768
|
if (res.status === 409) {
|
|
33565
33769
|
const body2 = await res.json().catch(() => ({}));
|
|
33566
33770
|
return {
|
|
33567
|
-
|
|
33771
|
+
builderId: getMutationId(
|
|
33772
|
+
body2,
|
|
33773
|
+
"builderId"
|
|
33774
|
+
),
|
|
33775
|
+
alreadyRegistered: true
|
|
33568
33776
|
};
|
|
33569
33777
|
}
|
|
33570
33778
|
if (!res.ok) {
|
|
33571
33779
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33572
33780
|
}
|
|
33573
|
-
const body = await res.json();
|
|
33781
|
+
const body = await res.json().catch(() => ({}));
|
|
33782
|
+
return {
|
|
33783
|
+
builderId: getMutationId(body, "builderId"),
|
|
33784
|
+
alreadyRegistered: false
|
|
33785
|
+
};
|
|
33786
|
+
},
|
|
33787
|
+
async registerDataPoint(params) {
|
|
33788
|
+
const res = await fetch(`${base}/v1/data`, {
|
|
33789
|
+
method: "POST",
|
|
33790
|
+
headers: {
|
|
33791
|
+
"Content-Type": "application/json",
|
|
33792
|
+
Authorization: `Web3Signed ${params.signature}`
|
|
33793
|
+
},
|
|
33794
|
+
body: JSON.stringify({
|
|
33795
|
+
ownerAddress: params.ownerAddress,
|
|
33796
|
+
scope: params.scope,
|
|
33797
|
+
dataHash: params.dataHash,
|
|
33798
|
+
metadataHash: params.metadataHash,
|
|
33799
|
+
expectedVersion: params.expectedVersion
|
|
33800
|
+
})
|
|
33801
|
+
});
|
|
33802
|
+
if (!res.ok) {
|
|
33803
|
+
const body2 = await res.json().catch(() => ({}));
|
|
33804
|
+
const detail = body2.error ?? res.statusText;
|
|
33805
|
+
throw new Error(`Gateway error: ${res.status} ${detail}`);
|
|
33806
|
+
}
|
|
33807
|
+
const body = await res.json().catch(() => ({}));
|
|
33574
33808
|
return {
|
|
33575
|
-
|
|
33809
|
+
dataPointId: getMutationId(
|
|
33810
|
+
body,
|
|
33811
|
+
"dataPointId"
|
|
33812
|
+
),
|
|
33813
|
+
expectedVersion: body.expectedVersion
|
|
33576
33814
|
};
|
|
33577
33815
|
},
|
|
33578
33816
|
async createGrant(params) {
|
|
@@ -33585,8 +33823,9 @@ function createGatewayClient(baseUrl) {
|
|
|
33585
33823
|
body: JSON.stringify({
|
|
33586
33824
|
grantorAddress: params.grantorAddress,
|
|
33587
33825
|
granteeId: params.granteeId,
|
|
33588
|
-
|
|
33589
|
-
|
|
33826
|
+
scopes: params.scopes,
|
|
33827
|
+
grantVersion: params.grantVersion,
|
|
33828
|
+
expiresAt: params.expiresAt
|
|
33590
33829
|
})
|
|
33591
33830
|
});
|
|
33592
33831
|
if (res.status === 409) {
|
|
@@ -33611,7 +33850,8 @@ function createGatewayClient(baseUrl) {
|
|
|
33611
33850
|
Authorization: `Web3Signed ${params.signature}`
|
|
33612
33851
|
},
|
|
33613
33852
|
body: JSON.stringify({
|
|
33614
|
-
grantorAddress: params.grantorAddress
|
|
33853
|
+
grantorAddress: params.grantorAddress,
|
|
33854
|
+
grantVersion: params.grantVersion
|
|
33615
33855
|
})
|
|
33616
33856
|
});
|
|
33617
33857
|
if (res.status === 409) return;
|
|
@@ -33619,21 +33859,62 @@ function createGatewayClient(baseUrl) {
|
|
|
33619
33859
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33620
33860
|
}
|
|
33621
33861
|
},
|
|
33622
|
-
async
|
|
33623
|
-
const res = await fetch(`${base}/v1/
|
|
33624
|
-
|
|
33862
|
+
async getEscrowBalance(account) {
|
|
33863
|
+
const res = await fetch(`${base}/v1/escrow/balance?account=${account}`);
|
|
33864
|
+
if (!res.ok) {
|
|
33865
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33866
|
+
}
|
|
33867
|
+
return await res.json();
|
|
33868
|
+
},
|
|
33869
|
+
async submitEscrowDeposit(params) {
|
|
33870
|
+
const res = await fetch(`${base}/v1/escrow/deposit`, {
|
|
33871
|
+
method: "POST",
|
|
33872
|
+
headers: { "Content-Type": "application/json" },
|
|
33873
|
+
body: JSON.stringify({ txHash: params.txHash })
|
|
33874
|
+
});
|
|
33875
|
+
if (res.status !== 200 && res.status !== 202) {
|
|
33876
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33877
|
+
}
|
|
33878
|
+
return await res.json();
|
|
33879
|
+
},
|
|
33880
|
+
async payForOperation(params) {
|
|
33881
|
+
const body = {
|
|
33882
|
+
payerAddress: params.payerAddress,
|
|
33883
|
+
opType: params.opType,
|
|
33884
|
+
opId: params.opId,
|
|
33885
|
+
asset: params.asset,
|
|
33886
|
+
amount: params.amount,
|
|
33887
|
+
paymentNonce: params.paymentNonce
|
|
33888
|
+
};
|
|
33889
|
+
if (params.accessRecord) {
|
|
33890
|
+
body["accessRecord"] = params.accessRecord;
|
|
33891
|
+
}
|
|
33892
|
+
const res = await fetch(`${base}/v1/escrow/pay`, {
|
|
33893
|
+
method: "POST",
|
|
33625
33894
|
headers: {
|
|
33626
33895
|
"Content-Type": "application/json",
|
|
33627
33896
|
Authorization: `Web3Signed ${params.signature}`
|
|
33628
33897
|
},
|
|
33629
|
-
body: JSON.stringify(
|
|
33630
|
-
ownerAddress: params.ownerAddress
|
|
33631
|
-
})
|
|
33898
|
+
body: JSON.stringify(body)
|
|
33632
33899
|
});
|
|
33633
|
-
if (res.status === 409) return;
|
|
33634
33900
|
if (!res.ok) {
|
|
33635
33901
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33636
33902
|
}
|
|
33903
|
+
return await res.json();
|
|
33904
|
+
},
|
|
33905
|
+
async settle(params) {
|
|
33906
|
+
const res = await fetch(`${base}/v1/settle`, {
|
|
33907
|
+
method: "POST",
|
|
33908
|
+
headers: { "Content-Type": "application/json" },
|
|
33909
|
+
// The gateway accepts an empty body; only `limit` is recognised.
|
|
33910
|
+
// Always send a JSON body so the gateway's req.body shape parse
|
|
33911
|
+
// doesn't have to deal with an undefined.
|
|
33912
|
+
body: JSON.stringify(params ?? {})
|
|
33913
|
+
});
|
|
33914
|
+
if (!res.ok) {
|
|
33915
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33916
|
+
}
|
|
33917
|
+
return await res.json();
|
|
33637
33918
|
}
|
|
33638
33919
|
};
|
|
33639
33920
|
}
|
|
@@ -33657,7 +33938,7 @@ function genericPaymentDomain(chainId, escrowContract) {
|
|
|
33657
33938
|
verifyingContract: escrowContract
|
|
33658
33939
|
};
|
|
33659
33940
|
}
|
|
33660
|
-
var
|
|
33941
|
+
var ESCROW_DEPOSIT_ABI2 = [
|
|
33661
33942
|
{
|
|
33662
33943
|
type: "function",
|
|
33663
33944
|
name: "depositNative",
|
|
@@ -33815,6 +34096,7 @@ async function parsePSError(response) {
|
|
|
33815
34096
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33816
34097
|
0 && (module.exports = {
|
|
33817
34098
|
ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
|
|
34099
|
+
ADD_DATA_TYPES,
|
|
33818
34100
|
AccountPersonalServerLiteOwnerBindingError,
|
|
33819
34101
|
AccountPersonalServerRegistrationError,
|
|
33820
34102
|
BUILDER_REGISTRATION_TYPES,
|
|
@@ -33824,13 +34106,14 @@ async function parsePSError(response) {
|
|
|
33824
34106
|
CallbackStorage,
|
|
33825
34107
|
ContractFactory,
|
|
33826
34108
|
ContractNotFoundError,
|
|
34109
|
+
DATA_REGISTRY_STATUS_ABI,
|
|
33827
34110
|
DataFileEnvelopeSchema,
|
|
34111
|
+
DataPointStatus,
|
|
33828
34112
|
DropboxStorage,
|
|
33829
34113
|
ECIESError,
|
|
33830
34114
|
ESCROW_DEPOSIT_ABI,
|
|
33831
34115
|
ExpiredTokenError,
|
|
33832
|
-
|
|
33833
|
-
FILE_REGISTRATION_TYPES,
|
|
34116
|
+
FEE_REGISTRY_ABI,
|
|
33834
34117
|
GENERIC_PAYMENT_TYPES,
|
|
33835
34118
|
GRANT_REGISTRATION_TYPES,
|
|
33836
34119
|
GRANT_REVOCATION_TYPES,
|
|
@@ -33843,6 +34126,7 @@ async function parsePSError(response) {
|
|
|
33843
34126
|
MASTER_KEY_MESSAGE,
|
|
33844
34127
|
MissingAuthError,
|
|
33845
34128
|
NATIVE_ASSET_ADDRESS,
|
|
34129
|
+
NATIVE_VANA_ASSET,
|
|
33846
34130
|
NetworkError,
|
|
33847
34131
|
NodeECIESProvider,
|
|
33848
34132
|
NodePlatformAdapter,
|
|
@@ -33860,6 +34144,8 @@ async function parsePSError(response) {
|
|
|
33860
34144
|
PersonalServerError,
|
|
33861
34145
|
PinataStorage,
|
|
33862
34146
|
R2Storage,
|
|
34147
|
+
RECORD_DATA_ACCESS_TYPES,
|
|
34148
|
+
REGISTRATION_KIND_FOR_OP,
|
|
33863
34149
|
ReadOnlyError,
|
|
33864
34150
|
RelayerError,
|
|
33865
34151
|
SERVER_REGISTRATION_TYPES,
|
|
@@ -33874,10 +34160,15 @@ async function parsePSError(response) {
|
|
|
33874
34160
|
VanaError,
|
|
33875
34161
|
VanaStorage,
|
|
33876
34162
|
assertValidPkceVerifier,
|
|
34163
|
+
buildDepositNativeRequest,
|
|
34164
|
+
buildDepositTokenRequest,
|
|
34165
|
+
buildMarkDataPointUnavailableRequest,
|
|
34166
|
+
buildPersonalServerDataReadRequest,
|
|
33877
34167
|
buildPersonalServerLiteOwnerBindingMessage,
|
|
33878
34168
|
buildPersonalServerLiteOwnerBindingSignature,
|
|
33879
34169
|
buildPersonalServerRegistrationSignature,
|
|
33880
34170
|
buildPersonalServerRegistrationTypedData,
|
|
34171
|
+
buildSetDataPointStatusRequest,
|
|
33881
34172
|
buildWeb3SignedHeader,
|
|
33882
34173
|
builderRegistrationDomain,
|
|
33883
34174
|
chains,
|
|
@@ -33896,14 +34187,19 @@ async function parsePSError(response) {
|
|
|
33896
34187
|
createVanaStorageProvider,
|
|
33897
34188
|
createViemPersonalServerLiteOwnerBindingSigner,
|
|
33898
34189
|
createViemPersonalServerRegistrationSigner,
|
|
34190
|
+
dataRegistryContractAddress,
|
|
34191
|
+
dataRegistryDomain,
|
|
33899
34192
|
decryptWithPassword,
|
|
33900
34193
|
deriveMasterKey,
|
|
33901
34194
|
deriveScopeKey,
|
|
33902
34195
|
deserializeECIES,
|
|
33903
34196
|
detectPlatform,
|
|
34197
|
+
encodeDepositNativeData,
|
|
34198
|
+
encodeDepositTokenData,
|
|
34199
|
+
encodeSetDataPointStatusData,
|
|
33904
34200
|
encryptWithPassword,
|
|
33905
|
-
|
|
33906
|
-
|
|
34201
|
+
escrowContractAddress,
|
|
34202
|
+
escrowPaymentDomain,
|
|
33907
34203
|
generatePkceVerifier,
|
|
33908
34204
|
genericPaymentDomain,
|
|
33909
34205
|
getAbi,
|
|
@@ -33912,6 +34208,8 @@ async function parsePSError(response) {
|
|
|
33912
34208
|
getContractAddress,
|
|
33913
34209
|
getContractController,
|
|
33914
34210
|
getContractInfo,
|
|
34211
|
+
getFee,
|
|
34212
|
+
getOpFee,
|
|
33915
34213
|
getPlatformCapabilities,
|
|
33916
34214
|
getServiceEndpoints,
|
|
33917
34215
|
grantRegistrationDomain,
|
|
@@ -33923,11 +34221,12 @@ async function parsePSError(response) {
|
|
|
33923
34221
|
moksha,
|
|
33924
34222
|
mokshaServices,
|
|
33925
34223
|
mokshaTestnet,
|
|
33926
|
-
parseGrantRegistrationPayload,
|
|
33927
34224
|
parsePSError,
|
|
33928
34225
|
parseScope,
|
|
33929
34226
|
parseWeb3SignedHeader,
|
|
34227
|
+
personalServerDataReadPath,
|
|
33930
34228
|
personalServerRegistrationDomain,
|
|
34229
|
+
readPersonalServerData,
|
|
33931
34230
|
recoverServerOwner,
|
|
33932
34231
|
registerPersonalServerSignature,
|
|
33933
34232
|
scopeCoveredByGrant,
|