@opendatalabs/vana-sdk 3.2.0-canary.88d802d → 3.2.0-canary.9bf69b3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.js +89 -1
- package/dist/index.browser.js.map +3 -3
- package/dist/index.node.cjs +93 -1
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +1 -0
- package/dist/index.node.js +89 -1
- package/dist/index.node.js.map +3 -3
- package/dist/protocol/eip712.cjs.map +1 -1
- package/dist/protocol/eip712.d.ts +1 -0
- package/dist/protocol/eip712.js.map +1 -1
- 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.map +1 -1
- package/dist/protocol/gateway.d.ts +1 -0
- package/dist/protocol/gateway.js.map +1 -1
- package/dist/protocol/grants.cjs +1 -1
- package/dist/protocol/grants.cjs.map +1 -1
- package/dist/protocol/grants.js +1 -1
- package/dist/protocol/grants.js.map +1 -1
- package/package.json +1 -1
package/dist/index.browser.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export { ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT, AccountPersonalServerRegis
|
|
|
42
42
|
export { AccountPersonalServerLiteOwnerBindingError, signPersonalServerLiteOwnerBindingWithAccountClient, type AccountPersonalServerLiteOwnerBindingClient, type SignPersonalServerLiteOwnerBindingWithAccountClientConfig, } from "./account/personal-server-lite-owner-binding";
|
|
43
43
|
export { isDataPortabilityGatewayConfig, verifyGrantRegistration, type VerifyGrantRegistrationInput, type VerifyGrantRegistrationResult, } from "./protocol/grants";
|
|
44
44
|
export { ESCROW_DEPOSIT_ABI, escrowContractAddress, encodeDepositNativeData, encodeDepositTokenData, buildDepositNativeRequest, buildDepositTokenRequest, type DepositNativeInput, type DepositTokenInput, type DepositTransactionRequest, } from "./protocol/escrow-deposit";
|
|
45
|
+
export { FEE_REGISTRY_ABI, REGISTRATION_KIND_FOR_OP, getFee, getOpFee, type FeeKind, type FeeEntry, type OpFee, type FeeRegistryOptions, } from "./protocol/fee-registry";
|
|
45
46
|
export { ScopeSchema, parseScope, scopeToPathSegments, scopeMatchesPattern, scopeCoveredByGrant, type Scope, type ParsedScope, } from "./protocol/scopes";
|
|
46
47
|
export { DataFileEnvelopeSchema, createDataFileEnvelope, IngestResponseSchema, type DataFileEnvelope, type IngestResponse, } from "./protocol/data-file";
|
|
47
48
|
export { createGatewayClient, type GatewayEnvelope, type GatewayProof, type Builder, type Schema, type ServerInfo, type GatewayGrantResponse, type GatewayGrantStatus, type GatewayGrantFee, type GrantListItem, type FileRecord, type FileListResult, type RegisterServerParams, type RegisterServerResult, type RegisterFileParams, type RegisterBuilderParams, type RegisterBuilderResult, type RegisterDataPointParams, type RegisterDataPointResult, type CreateGrantParams, type RevokeGrantParams, type PayForOperationParams, type PayForOperationResult, type AccessRecord, type SettleOpType, type SettleItem, type SettlePromoteResult, type SettleReconcileItem, type SettleParams, type SettleResult, type SubmitDepositParams, type DepositState, type EscrowBalance, type EscrowBalanceEntry, type EscrowDepositSubmitted, type EscrowDepositFinalized, type EscrowDepositFailed, type GatewayClient, } from "./protocol/gateway";
|
package/dist/index.browser.js
CHANGED
|
@@ -32441,7 +32441,7 @@ function isDataPortabilityGatewayConfig(value) {
|
|
|
32441
32441
|
return false;
|
|
32442
32442
|
}
|
|
32443
32443
|
const c = contracts;
|
|
32444
|
-
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]) && isHexString(c["dataPortabilityEscrow"]);
|
|
32444
|
+
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]) && isHexString(c["dataPortabilityEscrow"]) && isHexString(c["feeRegistry"]);
|
|
32445
32445
|
}
|
|
32446
32446
|
function toUint256(value) {
|
|
32447
32447
|
try {
|
|
@@ -32556,6 +32556,90 @@ function buildDepositTokenRequest(config, input) {
|
|
|
32556
32556
|
};
|
|
32557
32557
|
}
|
|
32558
32558
|
|
|
32559
|
+
// src/protocol/fee-registry.ts
|
|
32560
|
+
import { parseAbi } from "viem";
|
|
32561
|
+
var FEE_REGISTRY_ABI = parseAbi([
|
|
32562
|
+
"struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
|
|
32563
|
+
"function fees(bytes32 operation) view returns (Fee)",
|
|
32564
|
+
"function operationKey(string name) pure returns (bytes32)"
|
|
32565
|
+
]);
|
|
32566
|
+
var REGISTRATION_KIND_FOR_OP = {
|
|
32567
|
+
grant: "grant_registration",
|
|
32568
|
+
data: "data_registration",
|
|
32569
|
+
server: "server_registration",
|
|
32570
|
+
builder: "builder_registration"
|
|
32571
|
+
};
|
|
32572
|
+
function operationNameFor(kind, opts) {
|
|
32573
|
+
switch (kind) {
|
|
32574
|
+
case "grant_registration":
|
|
32575
|
+
return opts?.grantRegistrationOpName ?? "grant_registration";
|
|
32576
|
+
case "data_access":
|
|
32577
|
+
return opts?.dataAccessOpName ?? "data_access";
|
|
32578
|
+
case "data_registration":
|
|
32579
|
+
return opts?.dataRegistrationOpName ?? "data_registration";
|
|
32580
|
+
case "server_registration":
|
|
32581
|
+
return opts?.serverRegistrationOpName ?? "server_registration";
|
|
32582
|
+
case "builder_registration":
|
|
32583
|
+
return opts?.builderRegistrationOpName ?? "builder_registration";
|
|
32584
|
+
}
|
|
32585
|
+
}
|
|
32586
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
32587
|
+
async function getFee(client, config, kind, opts) {
|
|
32588
|
+
const address = config.contracts.feeRegistry;
|
|
32589
|
+
const opName = operationNameFor(kind, opts);
|
|
32590
|
+
const opKey = await client.readContract({
|
|
32591
|
+
address,
|
|
32592
|
+
abi: FEE_REGISTRY_ABI,
|
|
32593
|
+
functionName: "operationKey",
|
|
32594
|
+
args: [opName]
|
|
32595
|
+
});
|
|
32596
|
+
const fee = await client.readContract({
|
|
32597
|
+
address,
|
|
32598
|
+
abi: FEE_REGISTRY_ABI,
|
|
32599
|
+
functionName: "fees",
|
|
32600
|
+
args: [opKey]
|
|
32601
|
+
});
|
|
32602
|
+
if (fee.enabled && fee.payee === ZERO_ADDRESS) {
|
|
32603
|
+
throw new Error(
|
|
32604
|
+
`FeeRegistry: enabled operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
|
|
32605
|
+
);
|
|
32606
|
+
}
|
|
32607
|
+
return fee;
|
|
32608
|
+
}
|
|
32609
|
+
async function getOpFee(client, config, opType, opts) {
|
|
32610
|
+
const registrationKind = REGISTRATION_KIND_FOR_OP[opType];
|
|
32611
|
+
if (!registrationKind) {
|
|
32612
|
+
throw new Error(
|
|
32613
|
+
`getOpFee: unknown opType "${opType}" \u2014 supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(", ")}`
|
|
32614
|
+
);
|
|
32615
|
+
}
|
|
32616
|
+
const includeDataAccess = opType === "grant";
|
|
32617
|
+
const [registration, dataAccess] = await Promise.all([
|
|
32618
|
+
getFee(client, config, registrationKind, opts),
|
|
32619
|
+
includeDataAccess ? getFee(client, config, "data_access", opts) : Promise.resolve({
|
|
32620
|
+
amount: 0n,
|
|
32621
|
+
asset: ZERO_ADDRESS,
|
|
32622
|
+
payee: ZERO_ADDRESS,
|
|
32623
|
+
enabled: false
|
|
32624
|
+
})
|
|
32625
|
+
]);
|
|
32626
|
+
if (registration.enabled && dataAccess.enabled && registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
|
|
32627
|
+
throw new Error(
|
|
32628
|
+
`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.`
|
|
32629
|
+
);
|
|
32630
|
+
}
|
|
32631
|
+
const asset = registration.enabled ? registration.asset : dataAccess.enabled ? dataAccess.asset : ZERO_ADDRESS;
|
|
32632
|
+
return {
|
|
32633
|
+
asset,
|
|
32634
|
+
registrationFee: registration.enabled ? registration.amount : 0n,
|
|
32635
|
+
dataAccessFee: dataAccess.enabled ? dataAccess.amount : 0n,
|
|
32636
|
+
registrationEnabled: registration.enabled,
|
|
32637
|
+
dataAccessEnabled: dataAccess.enabled,
|
|
32638
|
+
registrationPayee: registration.enabled ? registration.payee : ZERO_ADDRESS,
|
|
32639
|
+
dataAccessPayee: dataAccess.enabled ? dataAccess.payee : ZERO_ADDRESS
|
|
32640
|
+
};
|
|
32641
|
+
}
|
|
32642
|
+
|
|
32559
32643
|
// src/protocol/scopes.ts
|
|
32560
32644
|
import { z } from "zod";
|
|
32561
32645
|
var SEGMENT_RE = /^[a-z0-9][a-z0-9_]*$/;
|
|
@@ -33027,6 +33111,7 @@ export {
|
|
|
33027
33111
|
ECIESError,
|
|
33028
33112
|
ESCROW_DEPOSIT_ABI,
|
|
33029
33113
|
ExpiredTokenError,
|
|
33114
|
+
FEE_REGISTRY_ABI,
|
|
33030
33115
|
FILE_REGISTRATION_TYPES,
|
|
33031
33116
|
GENERIC_PAYMENT_TYPES,
|
|
33032
33117
|
GRANT_REGISTRATION_TYPES,
|
|
@@ -33056,6 +33141,7 @@ export {
|
|
|
33056
33141
|
PinataStorage,
|
|
33057
33142
|
R2Storage,
|
|
33058
33143
|
RECORD_DATA_ACCESS_TYPES,
|
|
33144
|
+
REGISTRATION_KIND_FOR_OP,
|
|
33059
33145
|
ReadOnlyError,
|
|
33060
33146
|
RelayerError,
|
|
33061
33147
|
SERVER_REGISTRATION_TYPES,
|
|
@@ -33109,6 +33195,8 @@ export {
|
|
|
33109
33195
|
getContractAddress,
|
|
33110
33196
|
getContractController,
|
|
33111
33197
|
getContractInfo,
|
|
33198
|
+
getFee,
|
|
33199
|
+
getOpFee,
|
|
33112
33200
|
getPlatformCapabilities,
|
|
33113
33201
|
getServiceEndpoints,
|
|
33114
33202
|
grantRegistrationDomain,
|