@opendatalabs/vana-sdk 3.2.0-canary.255a8bf → 3.2.0-canary.2817fa3

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.
@@ -42,7 +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, getFee, getOpFee, type FeeKind, type FeeEntry, type OpFee, type FeeRegistryOptions, } from "./protocol/fee-registry";
45
+ export { FEE_REGISTRY_ABI, REGISTRATION_KIND_FOR_OP, getFee, getOpFee, type FeeKind, type FeeEntry, type OpFee, type FeeRegistryOptions, } from "./protocol/fee-registry";
46
46
  export { ScopeSchema, parseScope, scopeToPathSegments, scopeMatchesPattern, scopeCoveredByGrant, type Scope, type ParsedScope, } from "./protocol/scopes";
47
47
  export { DataFileEnvelopeSchema, createDataFileEnvelope, IngestResponseSchema, type DataFileEnvelope, type IngestResponse, } from "./protocol/data-file";
48
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";
@@ -32563,12 +32563,27 @@ var FEE_REGISTRY_ABI = parseAbi([
32563
32563
  "function fees(bytes32 operation) view returns (Fee)",
32564
32564
  "function operationKey(string name) pure returns (bytes32)"
32565
32565
  ]);
32566
+ var REGISTRATION_KIND_FOR_OP = {
32567
+ grant: "grant_registration",
32568
+ data: "data_registration",
32569
+ server: "server_registration",
32570
+ builder: "builder_registration"
32571
+ };
32566
32572
  function operationNameFor(kind, opts) {
32567
- if (kind === "registration") {
32568
- return opts?.registrationOpName ?? "registration";
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";
32569
32584
  }
32570
- return opts?.dataAccessOpName ?? "data_access";
32571
32585
  }
32586
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
32572
32587
  async function getFee(client, config, kind, opts) {
32573
32588
  const address = config.contracts.feeRegistry;
32574
32589
  const opName = operationNameFor(kind, opts);
@@ -32584,34 +32599,44 @@ async function getFee(client, config, kind, opts) {
32584
32599
  functionName: "fees",
32585
32600
  args: [opKey]
32586
32601
  });
32587
- if (!fee.enabled) {
32602
+ if (fee.enabled && fee.payee === ZERO_ADDRESS) {
32588
32603
  throw new Error(
32589
- `FeeRegistry: operation "${opName}" (kind=${kind}) is not enabled \u2014 operator must call setFeeByName before payments will validate`
32604
+ `FeeRegistry: enabled operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
32590
32605
  );
32591
32606
  }
32592
- if (fee.payee === "0x0000000000000000000000000000000000000000") {
32607
+ return fee;
32608
+ }
32609
+ async function getOpFee(client, config, opType, opts) {
32610
+ const registrationKind = REGISTRATION_KIND_FOR_OP[opType];
32611
+ if (!registrationKind) {
32593
32612
  throw new Error(
32594
- `FeeRegistry: operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
32613
+ `getOpFee: unknown opType "${opType}" \u2014 supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(", ")}`
32595
32614
  );
32596
32615
  }
32597
- return fee;
32598
- }
32599
- async function getOpFee(client, config, opts) {
32616
+ const includeDataAccess = opType === "grant";
32600
32617
  const [registration, dataAccess] = await Promise.all([
32601
- getFee(client, config, "registration", opts),
32602
- getFee(client, config, "data_access", opts)
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
+ })
32603
32625
  ]);
32604
- if (registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
32626
+ if (registration.enabled && dataAccess.enabled && registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
32605
32627
  throw new Error(
32606
- `FeeRegistry asset mismatch: registration=${registration.asset} vs data_access=${dataAccess.asset}. The gateway requires both fees to settle in the same asset.`
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.`
32607
32629
  );
32608
32630
  }
32631
+ const asset = registration.enabled ? registration.asset : dataAccess.enabled ? dataAccess.asset : ZERO_ADDRESS;
32609
32632
  return {
32610
- asset: registration.asset,
32611
- registrationFee: registration.amount,
32612
- dataAccessFee: dataAccess.amount,
32613
- registrationPayee: registration.payee,
32614
- dataAccessPayee: dataAccess.payee
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
32615
32640
  };
32616
32641
  }
32617
32642
 
@@ -33116,6 +33141,7 @@ export {
33116
33141
  PinataStorage,
33117
33142
  R2Storage,
33118
33143
  RECORD_DATA_ACCESS_TYPES,
33144
+ REGISTRATION_KIND_FOR_OP,
33119
33145
  ReadOnlyError,
33120
33146
  RelayerError,
33121
33147
  SERVER_REGISTRATION_TYPES,