@opendatalabs/vana-sdk 3.4.1-canary.e9d0aad → 3.5.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/dist/account/personal-server-lite-owner-binding.cjs +3 -3
- package/dist/account/personal-server-lite-owner-binding.cjs.map +1 -1
- package/dist/account/personal-server-lite-owner-binding.d.ts +2 -2
- package/dist/account/personal-server-lite-owner-binding.js +1 -1
- package/dist/account/personal-server-lite-owner-binding.js.map +1 -1
- package/dist/index.browser.d.ts +5 -8
- package/dist/index.browser.js +250 -416
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +258 -439
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +5 -8
- package/dist/index.node.js +250 -416
- package/dist/index.node.js.map +4 -4
- package/dist/{protocol/personal-server-lite-owner-binding.cjs → personal-server-lite/owner-binding.cjs} +5 -5
- package/dist/personal-server-lite/owner-binding.cjs.map +1 -0
- package/dist/{protocol/personal-server-lite-owner-binding.d.ts → personal-server-lite/owner-binding.d.ts} +3 -3
- package/dist/{protocol/personal-server-lite-owner-binding.js → personal-server-lite/owner-binding.js} +2 -2
- package/dist/personal-server-lite/owner-binding.js.map +1 -0
- package/dist/protocol/eip712.cjs +31 -53
- package/dist/protocol/eip712.cjs.map +1 -1
- package/dist/protocol/eip712.d.ts +43 -98
- package/dist/protocol/eip712.js +27 -47
- package/dist/protocol/eip712.js.map +1 -1
- package/dist/protocol/escrow.cjs +146 -0
- package/dist/protocol/escrow.cjs.map +1 -0
- package/dist/protocol/escrow.d.ts +336 -0
- package/dist/protocol/escrow.js +118 -0
- package/dist/protocol/escrow.js.map +1 -0
- package/dist/protocol/gateway.cjs +37 -107
- package/dist/protocol/gateway.cjs.map +1 -1
- package/dist/protocol/gateway.d.ts +57 -223
- package/dist/protocol/gateway.js +37 -107
- package/dist/protocol/gateway.js.map +1 -1
- package/dist/protocol/grants.cjs +64 -27
- package/dist/protocol/grants.cjs.map +1 -1
- package/dist/protocol/grants.d.ts +13 -6
- package/dist/protocol/grants.js +63 -27
- package/dist/protocol/grants.js.map +1 -1
- package/dist/protocol/personal-server-registration.cjs +16 -4
- package/dist/protocol/personal-server-registration.cjs.map +1 -1
- package/dist/protocol/personal-server-registration.d.ts +5 -2
- package/dist/protocol/personal-server-registration.js +16 -4
- package/dist/protocol/personal-server-registration.js.map +1 -1
- package/package.json +2 -3
- package/dist/protocol/data-point-status.cjs +0 -80
- package/dist/protocol/data-point-status.cjs.map +0 -1
- package/dist/protocol/data-point-status.d.ts +0 -34
- package/dist/protocol/data-point-status.js +0 -51
- package/dist/protocol/data-point-status.js.map +0 -1
- package/dist/protocol/escrow-deposit.cjs +0 -89
- package/dist/protocol/escrow-deposit.cjs.map +0 -1
- package/dist/protocol/escrow-deposit.d.ts +0 -47
- package/dist/protocol/escrow-deposit.js +0 -60
- package/dist/protocol/escrow-deposit.js.map +0 -1
- package/dist/protocol/escrow-flow.test.d.ts +0 -21
- package/dist/protocol/fee-registry.cjs +0 -116
- package/dist/protocol/fee-registry.cjs.map +0 -1
- package/dist/protocol/fee-registry.d.ts +0 -151
- package/dist/protocol/fee-registry.js +0 -89
- package/dist/protocol/fee-registry.js.map +0 -1
- package/dist/protocol/fee-registry.test.d.ts +0 -1
- package/dist/protocol/personal-server-data.cjs +0 -71
- package/dist/protocol/personal-server-data.cjs.map +0 -1
- package/dist/protocol/personal-server-data.d.ts +0 -16
- package/dist/protocol/personal-server-data.js +0 -47
- package/dist/protocol/personal-server-data.js.map +0 -1
- package/dist/protocol/personal-server-data.test.d.ts +0 -1
- package/dist/protocol/personal-server-lite-owner-binding.cjs.map +0 -1
- package/dist/protocol/personal-server-lite-owner-binding.js.map +0 -1
- package/dist/protocol/personal-server-lite-owner-binding.test.d.ts +0 -1
- /package/dist/{protocol/data-point-status.test.d.ts → personal-server-lite/owner-binding.test.d.ts} +0 -0
- /package/dist/protocol/{escrow-deposit.test.d.ts → escrow.test.d.ts} +0 -0
package/dist/index.node.js
CHANGED
|
@@ -32509,7 +32509,6 @@ function formatOAuthError(body, status) {
|
|
|
32509
32509
|
// src/protocol/eip712.ts
|
|
32510
32510
|
var DOMAIN_NAME = "Vana Data Portability";
|
|
32511
32511
|
var DOMAIN_VERSION = "1";
|
|
32512
|
-
var NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
|
|
32513
32512
|
function buildDomain(chainId, verifyingContract) {
|
|
32514
32513
|
return {
|
|
32515
32514
|
name: DOMAIN_NAME,
|
|
@@ -32518,7 +32517,13 @@ function buildDomain(chainId, verifyingContract) {
|
|
|
32518
32517
|
verifyingContract
|
|
32519
32518
|
};
|
|
32520
32519
|
}
|
|
32521
|
-
function
|
|
32520
|
+
function fileRegistrationDomain(config) {
|
|
32521
|
+
return buildDomain(
|
|
32522
|
+
config.chainId,
|
|
32523
|
+
config.contracts.dataRegistry
|
|
32524
|
+
);
|
|
32525
|
+
}
|
|
32526
|
+
function fileDeletionDomain(config) {
|
|
32522
32527
|
return buildDomain(
|
|
32523
32528
|
config.chainId,
|
|
32524
32529
|
config.contracts.dataRegistry
|
|
@@ -32548,26 +32553,31 @@ function builderRegistrationDomain(config) {
|
|
|
32548
32553
|
config.contracts.dataPortabilityGrantees
|
|
32549
32554
|
);
|
|
32550
32555
|
}
|
|
32551
|
-
|
|
32552
|
-
|
|
32553
|
-
|
|
32554
|
-
|
|
32555
|
-
|
|
32556
|
-
|
|
32556
|
+
var FILE_REGISTRATION_TYPES = {
|
|
32557
|
+
FileRegistration: [
|
|
32558
|
+
{ name: "ownerAddress", type: "address" },
|
|
32559
|
+
{ name: "url", type: "string" },
|
|
32560
|
+
{ name: "schemaId", type: "bytes32" }
|
|
32561
|
+
]
|
|
32562
|
+
};
|
|
32563
|
+
var FILE_DELETION_TYPES = {
|
|
32564
|
+
FileDeletion: [
|
|
32565
|
+
{ name: "ownerAddress", type: "address" },
|
|
32566
|
+
{ name: "fileId", type: "bytes32" }
|
|
32567
|
+
]
|
|
32568
|
+
};
|
|
32557
32569
|
var GRANT_REGISTRATION_TYPES = {
|
|
32558
32570
|
GrantRegistration: [
|
|
32559
32571
|
{ name: "grantorAddress", type: "address" },
|
|
32560
32572
|
{ name: "granteeId", type: "bytes32" },
|
|
32561
|
-
{ name: "
|
|
32562
|
-
{ name: "
|
|
32563
|
-
{ name: "expiresAt", type: "uint256" }
|
|
32573
|
+
{ name: "grant", type: "string" },
|
|
32574
|
+
{ name: "fileIds", type: "uint256[]" }
|
|
32564
32575
|
]
|
|
32565
32576
|
};
|
|
32566
32577
|
var GRANT_REVOCATION_TYPES = {
|
|
32567
32578
|
GrantRevocation: [
|
|
32568
32579
|
{ name: "grantorAddress", type: "address" },
|
|
32569
|
-
{ name: "grantId", type: "bytes32" }
|
|
32570
|
-
{ name: "grantVersion", type: "uint256" }
|
|
32580
|
+
{ name: "grantId", type: "bytes32" }
|
|
32571
32581
|
]
|
|
32572
32582
|
};
|
|
32573
32583
|
var SERVER_REGISTRATION_TYPES = {
|
|
@@ -32586,41 +32596,16 @@ var BUILDER_REGISTRATION_TYPES = {
|
|
|
32586
32596
|
{ name: "appUrl", type: "string" }
|
|
32587
32597
|
]
|
|
32588
32598
|
};
|
|
32589
|
-
var GENERIC_PAYMENT_TYPES = {
|
|
32590
|
-
GenericPayment: [
|
|
32591
|
-
{ name: "payerAddress", type: "address" },
|
|
32592
|
-
{ name: "opType", type: "string" },
|
|
32593
|
-
{ name: "opId", type: "bytes32" },
|
|
32594
|
-
{ name: "asset", type: "address" },
|
|
32595
|
-
{ name: "amount", type: "uint256" },
|
|
32596
|
-
{ name: "paymentNonce", type: "uint256" }
|
|
32597
|
-
]
|
|
32598
|
-
};
|
|
32599
|
-
var ADD_DATA_TYPES = {
|
|
32600
|
-
AddData: [
|
|
32601
|
-
{ name: "ownerAddress", type: "address" },
|
|
32602
|
-
{ name: "scope", type: "string" },
|
|
32603
|
-
{ name: "dataHash", type: "bytes32" },
|
|
32604
|
-
{ name: "metadataHash", type: "bytes32" },
|
|
32605
|
-
{ name: "expectedVersion", type: "uint256" }
|
|
32606
|
-
]
|
|
32607
|
-
};
|
|
32608
|
-
var RECORD_DATA_ACCESS_TYPES = {
|
|
32609
|
-
RecordDataAccess: [
|
|
32610
|
-
{ name: "ownerAddress", type: "address" },
|
|
32611
|
-
{ name: "scope", type: "string" },
|
|
32612
|
-
{ name: "version", type: "uint256" },
|
|
32613
|
-
{ name: "accessor", type: "address" },
|
|
32614
|
-
{ name: "recordId", type: "bytes32" }
|
|
32615
|
-
]
|
|
32616
|
-
};
|
|
32617
32599
|
|
|
32618
32600
|
// src/protocol/personal-server-registration.ts
|
|
32619
32601
|
import {
|
|
32620
32602
|
isAddress
|
|
32621
32603
|
} from "viem";
|
|
32622
|
-
var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID =
|
|
32623
|
-
var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT =
|
|
32604
|
+
var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = vanaMainnet2.id;
|
|
32605
|
+
var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = getContractAddress(
|
|
32606
|
+
PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
|
|
32607
|
+
"DataPortabilityServers"
|
|
32608
|
+
);
|
|
32624
32609
|
function assertAddress(value, name) {
|
|
32625
32610
|
if (!isAddress(value)) {
|
|
32626
32611
|
throw new Error(`${name} must be a valid EVM address`);
|
|
@@ -32635,6 +32620,12 @@ function getAccountAddress(account) {
|
|
|
32635
32620
|
function isPersonalServerRegistrationSigner(source) {
|
|
32636
32621
|
return "address" in source && typeof source.signTypedData === "function";
|
|
32637
32622
|
}
|
|
32623
|
+
function getDefaultServerRegistrationContract(chainId) {
|
|
32624
|
+
return getContractAddress(
|
|
32625
|
+
chainId,
|
|
32626
|
+
"DataPortabilityServers"
|
|
32627
|
+
);
|
|
32628
|
+
}
|
|
32638
32629
|
function createViemPersonalServerRegistrationSigner(source, options = {}) {
|
|
32639
32630
|
if (isPersonalServerRegistrationSigner(source)) {
|
|
32640
32631
|
return source;
|
|
@@ -32657,12 +32648,13 @@ function personalServerRegistrationDomain(input = {}) {
|
|
|
32657
32648
|
if (input.config) {
|
|
32658
32649
|
return serverRegistrationDomain(input.config);
|
|
32659
32650
|
}
|
|
32660
|
-
const
|
|
32651
|
+
const chainId = input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID;
|
|
32652
|
+
const verifyingContract = input.verifyingContract ?? getDefaultServerRegistrationContract(chainId);
|
|
32661
32653
|
assertAddress(verifyingContract, "verifyingContract");
|
|
32662
32654
|
return {
|
|
32663
32655
|
name: "Vana Data Portability",
|
|
32664
32656
|
version: "1",
|
|
32665
|
-
chainId
|
|
32657
|
+
chainId,
|
|
32666
32658
|
verifyingContract
|
|
32667
32659
|
};
|
|
32668
32660
|
}
|
|
@@ -32700,11 +32692,11 @@ async function buildPersonalServerRegistrationSignature(input) {
|
|
|
32700
32692
|
}
|
|
32701
32693
|
var registerPersonalServerSignature = buildPersonalServerRegistrationSignature;
|
|
32702
32694
|
|
|
32703
|
-
// src/
|
|
32695
|
+
// src/personal-server-lite/owner-binding.ts
|
|
32704
32696
|
import {
|
|
32705
32697
|
isAddress as isAddress2
|
|
32706
32698
|
} from "viem";
|
|
32707
|
-
var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.
|
|
32699
|
+
var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.ps-lite.owner-binding.v1";
|
|
32708
32700
|
var PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
|
|
32709
32701
|
var PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
|
|
32710
32702
|
function assertAddress2(value, name) {
|
|
@@ -33055,34 +33047,67 @@ function isDataPortabilityGatewayConfig(value) {
|
|
|
33055
33047
|
return false;
|
|
33056
33048
|
}
|
|
33057
33049
|
const c = contracts;
|
|
33058
|
-
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"])
|
|
33050
|
+
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]);
|
|
33059
33051
|
}
|
|
33060
|
-
function
|
|
33052
|
+
function parseGrantRegistrationPayload(grant) {
|
|
33053
|
+
let parsed;
|
|
33061
33054
|
try {
|
|
33062
|
-
|
|
33063
|
-
return null;
|
|
33064
|
-
}
|
|
33065
|
-
const big = typeof value === "bigint" ? value : BigInt(value);
|
|
33066
|
-
if (big < 0n) return null;
|
|
33067
|
-
return big;
|
|
33055
|
+
parsed = JSON.parse(grant);
|
|
33068
33056
|
} catch {
|
|
33069
33057
|
return null;
|
|
33070
33058
|
}
|
|
33071
|
-
|
|
33072
|
-
|
|
33073
|
-
|
|
33074
|
-
|
|
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;
|
|
33075
33077
|
}
|
|
33076
|
-
if (
|
|
33077
|
-
return
|
|
33078
|
+
if (value["nonce"] !== void 0 && (typeof value["nonce"] !== "number" || !Number.isFinite(value["nonce"]))) {
|
|
33079
|
+
return null;
|
|
33078
33080
|
}
|
|
33079
|
-
|
|
33080
|
-
|
|
33081
|
-
|
|
33081
|
+
return {
|
|
33082
|
+
user: value["user"],
|
|
33083
|
+
builder: value["builder"],
|
|
33084
|
+
scopes: value["scopes"],
|
|
33085
|
+
expiresAt: value["expiresAt"],
|
|
33086
|
+
nonce: value["nonce"]
|
|
33087
|
+
};
|
|
33088
|
+
}
|
|
33089
|
+
function parseFileIds(fileIds) {
|
|
33090
|
+
try {
|
|
33091
|
+
const values = (fileIds ?? []).map((fileId) => BigInt(fileId));
|
|
33092
|
+
return {
|
|
33093
|
+
values,
|
|
33094
|
+
display: values.map((fileId) => fileId.toString())
|
|
33095
|
+
};
|
|
33096
|
+
} catch {
|
|
33097
|
+
return null;
|
|
33082
33098
|
}
|
|
33083
|
-
|
|
33084
|
-
|
|
33085
|
-
|
|
33099
|
+
}
|
|
33100
|
+
async function verifyGrantRegistration(input) {
|
|
33101
|
+
const payload = parseGrantRegistrationPayload(input.grant);
|
|
33102
|
+
if (!payload) {
|
|
33103
|
+
return {
|
|
33104
|
+
valid: false,
|
|
33105
|
+
error: "Grant must be JSON with scopes and expiresAt"
|
|
33106
|
+
};
|
|
33107
|
+
}
|
|
33108
|
+
const fileIds = parseFileIds(input.fileIds);
|
|
33109
|
+
if (!fileIds) {
|
|
33110
|
+
return { valid: false, error: "fileIds must contain integer values" };
|
|
33086
33111
|
}
|
|
33087
33112
|
let valid;
|
|
33088
33113
|
try {
|
|
@@ -33094,9 +33119,8 @@ async function verifyGrantRegistration(input) {
|
|
|
33094
33119
|
message: {
|
|
33095
33120
|
grantorAddress: input.grantorAddress,
|
|
33096
33121
|
granteeId: input.granteeId,
|
|
33097
|
-
|
|
33098
|
-
|
|
33099
|
-
expiresAt
|
|
33122
|
+
grant: input.grant,
|
|
33123
|
+
fileIds: fileIds.values
|
|
33100
33124
|
},
|
|
33101
33125
|
signature: input.signature
|
|
33102
33126
|
});
|
|
@@ -33107,197 +33131,19 @@ async function verifyGrantRegistration(input) {
|
|
|
33107
33131
|
return { valid: false, error: "Grant signature does not match grantor" };
|
|
33108
33132
|
}
|
|
33109
33133
|
const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
|
|
33110
|
-
if (expiresAt >
|
|
33134
|
+
if (payload.expiresAt > 0 && payload.expiresAt < nowSeconds) {
|
|
33111
33135
|
return { valid: false, error: "Grant has expired" };
|
|
33112
33136
|
}
|
|
33137
|
+
if (payload.user !== void 0 && payload.user.toLowerCase() !== input.grantorAddress.toLowerCase()) {
|
|
33138
|
+
return { valid: false, error: "Grant user does not match grantorAddress" };
|
|
33139
|
+
}
|
|
33113
33140
|
return {
|
|
33114
33141
|
valid: true,
|
|
33115
33142
|
grantorAddress: input.grantorAddress,
|
|
33116
33143
|
granteeId: input.granteeId,
|
|
33117
|
-
|
|
33118
|
-
|
|
33119
|
-
|
|
33120
|
-
};
|
|
33121
|
-
}
|
|
33122
|
-
|
|
33123
|
-
// src/protocol/escrow-deposit.ts
|
|
33124
|
-
import { encodeFunctionData } from "viem";
|
|
33125
|
-
var ESCROW_DEPOSIT_ABI = [
|
|
33126
|
-
{
|
|
33127
|
-
type: "function",
|
|
33128
|
-
name: "depositNative",
|
|
33129
|
-
stateMutability: "payable",
|
|
33130
|
-
inputs: [{ name: "account", type: "address" }],
|
|
33131
|
-
outputs: []
|
|
33132
|
-
},
|
|
33133
|
-
{
|
|
33134
|
-
type: "function",
|
|
33135
|
-
name: "depositToken",
|
|
33136
|
-
stateMutability: "nonpayable",
|
|
33137
|
-
inputs: [
|
|
33138
|
-
{ name: "account", type: "address" },
|
|
33139
|
-
{ name: "token", type: "address" },
|
|
33140
|
-
{ name: "amount", type: "uint256" }
|
|
33141
|
-
],
|
|
33142
|
-
outputs: []
|
|
33143
|
-
}
|
|
33144
|
-
];
|
|
33145
|
-
function escrowContractAddress(config) {
|
|
33146
|
-
return config.contracts.dataPortabilityEscrow;
|
|
33147
|
-
}
|
|
33148
|
-
function encodeDepositNativeData(input) {
|
|
33149
|
-
return encodeFunctionData({
|
|
33150
|
-
abi: ESCROW_DEPOSIT_ABI,
|
|
33151
|
-
functionName: "depositNative",
|
|
33152
|
-
args: [input.account]
|
|
33153
|
-
});
|
|
33154
|
-
}
|
|
33155
|
-
function encodeDepositTokenData(input) {
|
|
33156
|
-
return encodeFunctionData({
|
|
33157
|
-
abi: ESCROW_DEPOSIT_ABI,
|
|
33158
|
-
functionName: "depositToken",
|
|
33159
|
-
args: [input.account, input.token, input.amount]
|
|
33160
|
-
});
|
|
33161
|
-
}
|
|
33162
|
-
function buildDepositNativeRequest(config, input) {
|
|
33163
|
-
return {
|
|
33164
|
-
to: escrowContractAddress(config),
|
|
33165
|
-
data: encodeDepositNativeData({ account: input.account }),
|
|
33166
|
-
value: input.amount
|
|
33167
|
-
};
|
|
33168
|
-
}
|
|
33169
|
-
function buildDepositTokenRequest(config, input) {
|
|
33170
|
-
return {
|
|
33171
|
-
to: escrowContractAddress(config),
|
|
33172
|
-
data: encodeDepositTokenData(input)
|
|
33173
|
-
};
|
|
33174
|
-
}
|
|
33175
|
-
|
|
33176
|
-
// src/protocol/data-point-status.ts
|
|
33177
|
-
import { encodeFunctionData as encodeFunctionData2 } from "viem";
|
|
33178
|
-
var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
|
|
33179
|
-
DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
|
|
33180
|
-
DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
|
|
33181
|
-
DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
|
|
33182
|
-
DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
|
|
33183
|
-
return DataPointStatus2;
|
|
33184
|
-
})(DataPointStatus || {});
|
|
33185
|
-
var DATA_REGISTRY_STATUS_ABI = [
|
|
33186
|
-
{
|
|
33187
|
-
type: "function",
|
|
33188
|
-
name: "setStatus",
|
|
33189
|
-
stateMutability: "nonpayable",
|
|
33190
|
-
inputs: [
|
|
33191
|
-
{ name: "scope", type: "string" },
|
|
33192
|
-
{ name: "newStatus", type: "uint8" }
|
|
33193
|
-
],
|
|
33194
|
-
outputs: []
|
|
33195
|
-
}
|
|
33196
|
-
];
|
|
33197
|
-
function dataRegistryContractAddress(config) {
|
|
33198
|
-
return config.contracts.dataRegistry;
|
|
33199
|
-
}
|
|
33200
|
-
function encodeSetDataPointStatusData(input) {
|
|
33201
|
-
return encodeFunctionData2({
|
|
33202
|
-
abi: DATA_REGISTRY_STATUS_ABI,
|
|
33203
|
-
functionName: "setStatus",
|
|
33204
|
-
args: [input.scope, input.status]
|
|
33205
|
-
});
|
|
33206
|
-
}
|
|
33207
|
-
function buildSetDataPointStatusRequest(config, input) {
|
|
33208
|
-
return {
|
|
33209
|
-
to: dataRegistryContractAddress(config),
|
|
33210
|
-
data: encodeSetDataPointStatusData(input)
|
|
33211
|
-
};
|
|
33212
|
-
}
|
|
33213
|
-
function buildMarkDataPointUnavailableRequest(config, input) {
|
|
33214
|
-
return buildSetDataPointStatusRequest(config, {
|
|
33215
|
-
scope: input.scope,
|
|
33216
|
-
status: 3 /* Unavailable */
|
|
33217
|
-
});
|
|
33218
|
-
}
|
|
33219
|
-
|
|
33220
|
-
// src/protocol/fee-registry.ts
|
|
33221
|
-
import { parseAbi } from "viem";
|
|
33222
|
-
var FEE_REGISTRY_ABI = parseAbi([
|
|
33223
|
-
"struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
|
|
33224
|
-
"function fees(bytes32 operation) view returns (Fee)",
|
|
33225
|
-
"function operationKey(string name) pure returns (bytes32)"
|
|
33226
|
-
]);
|
|
33227
|
-
var REGISTRATION_KIND_FOR_OP = {
|
|
33228
|
-
grant: "grant_registration",
|
|
33229
|
-
data: "data_registration",
|
|
33230
|
-
server: "server_registration",
|
|
33231
|
-
builder: "builder_registration"
|
|
33232
|
-
};
|
|
33233
|
-
function operationNameFor(kind, opts) {
|
|
33234
|
-
switch (kind) {
|
|
33235
|
-
case "grant_registration":
|
|
33236
|
-
return opts?.grantRegistrationOpName ?? "grant_registration";
|
|
33237
|
-
case "data_access":
|
|
33238
|
-
return opts?.dataAccessOpName ?? "data_access";
|
|
33239
|
-
case "data_registration":
|
|
33240
|
-
return opts?.dataRegistrationOpName ?? "data_registration";
|
|
33241
|
-
case "server_registration":
|
|
33242
|
-
return opts?.serverRegistrationOpName ?? "server_registration";
|
|
33243
|
-
case "builder_registration":
|
|
33244
|
-
return opts?.builderRegistrationOpName ?? "builder_registration";
|
|
33245
|
-
}
|
|
33246
|
-
}
|
|
33247
|
-
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
33248
|
-
async function getFee(client, config, kind, opts) {
|
|
33249
|
-
const address = config.contracts.feeRegistry;
|
|
33250
|
-
const opName = operationNameFor(kind, opts);
|
|
33251
|
-
const opKey = await client.readContract({
|
|
33252
|
-
address,
|
|
33253
|
-
abi: FEE_REGISTRY_ABI,
|
|
33254
|
-
functionName: "operationKey",
|
|
33255
|
-
args: [opName]
|
|
33256
|
-
});
|
|
33257
|
-
const fee = await client.readContract({
|
|
33258
|
-
address,
|
|
33259
|
-
abi: FEE_REGISTRY_ABI,
|
|
33260
|
-
functionName: "fees",
|
|
33261
|
-
args: [opKey]
|
|
33262
|
-
});
|
|
33263
|
-
if (fee.enabled && fee.payee === ZERO_ADDRESS) {
|
|
33264
|
-
throw new Error(
|
|
33265
|
-
`FeeRegistry: enabled operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
|
|
33266
|
-
);
|
|
33267
|
-
}
|
|
33268
|
-
return fee;
|
|
33269
|
-
}
|
|
33270
|
-
async function getOpFee(client, config, opType, opts) {
|
|
33271
|
-
const registrationKind = REGISTRATION_KIND_FOR_OP[opType];
|
|
33272
|
-
if (!registrationKind) {
|
|
33273
|
-
throw new Error(
|
|
33274
|
-
`getOpFee: unknown opType "${opType}" \u2014 supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(", ")}`
|
|
33275
|
-
);
|
|
33276
|
-
}
|
|
33277
|
-
const includeDataAccess = opType === "grant";
|
|
33278
|
-
const [registration, dataAccess] = await Promise.all([
|
|
33279
|
-
getFee(client, config, registrationKind, opts),
|
|
33280
|
-
includeDataAccess ? getFee(client, config, "data_access", opts) : Promise.resolve({
|
|
33281
|
-
amount: 0n,
|
|
33282
|
-
asset: ZERO_ADDRESS,
|
|
33283
|
-
payee: ZERO_ADDRESS,
|
|
33284
|
-
enabled: false
|
|
33285
|
-
})
|
|
33286
|
-
]);
|
|
33287
|
-
if (registration.enabled && dataAccess.enabled && registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
|
|
33288
|
-
throw new Error(
|
|
33289
|
-
`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.`
|
|
33290
|
-
);
|
|
33291
|
-
}
|
|
33292
|
-
const asset = registration.enabled ? registration.asset : dataAccess.enabled ? dataAccess.asset : ZERO_ADDRESS;
|
|
33293
|
-
return {
|
|
33294
|
-
asset,
|
|
33295
|
-
registrationFee: registration.enabled ? registration.amount : 0n,
|
|
33296
|
-
dataAccessFee: dataAccess.enabled ? dataAccess.amount : 0n,
|
|
33297
|
-
registrationEnabled: registration.enabled,
|
|
33298
|
-
dataAccessEnabled: dataAccess.enabled,
|
|
33299
|
-
registrationPayee: registration.enabled ? registration.payee : ZERO_ADDRESS,
|
|
33300
|
-
dataAccessPayee: dataAccess.enabled ? dataAccess.payee : ZERO_ADDRESS
|
|
33144
|
+
grant: input.grant,
|
|
33145
|
+
payload,
|
|
33146
|
+
fileIds: fileIds.display
|
|
33301
33147
|
};
|
|
33302
33148
|
}
|
|
33303
33149
|
|
|
@@ -33371,45 +33217,6 @@ var IngestResponseSchema = z2.object({
|
|
|
33371
33217
|
status: z2.enum(["stored", "syncing"])
|
|
33372
33218
|
});
|
|
33373
33219
|
|
|
33374
|
-
// src/protocol/personal-server-data.ts
|
|
33375
|
-
function personalServerDataReadPath(scope) {
|
|
33376
|
-
return `/v1/data/${encodeURIComponent(scope)}`;
|
|
33377
|
-
}
|
|
33378
|
-
async function buildPersonalServerDataReadRequest(params) {
|
|
33379
|
-
const path = personalServerDataReadPath(params.scope);
|
|
33380
|
-
const baseUrl = params.personalServerUrl.replace(/\/+$/, "");
|
|
33381
|
-
const audience = params.audience ?? baseUrl;
|
|
33382
|
-
const headers = new Headers(params.headers);
|
|
33383
|
-
headers.set(
|
|
33384
|
-
"Authorization",
|
|
33385
|
-
await buildWeb3SignedHeader({
|
|
33386
|
-
aud: audience,
|
|
33387
|
-
grantId: params.grantId,
|
|
33388
|
-
method: "GET",
|
|
33389
|
-
signMessage: params.signMessage,
|
|
33390
|
-
uri: path
|
|
33391
|
-
})
|
|
33392
|
-
);
|
|
33393
|
-
return new Request(`${baseUrl}${path}`, {
|
|
33394
|
-
headers,
|
|
33395
|
-
method: "GET"
|
|
33396
|
-
});
|
|
33397
|
-
}
|
|
33398
|
-
async function readPersonalServerData(params) {
|
|
33399
|
-
const fetchFn = params.fetch ?? globalThis.fetch;
|
|
33400
|
-
if (fetchFn === void 0) {
|
|
33401
|
-
throw new Error("No fetch implementation available");
|
|
33402
|
-
}
|
|
33403
|
-
const request = await buildPersonalServerDataReadRequest(params);
|
|
33404
|
-
const response = await fetchFn(request);
|
|
33405
|
-
if (!response.ok) {
|
|
33406
|
-
throw new Error(
|
|
33407
|
-
`Personal Server data read failed: ${response.status} ${response.statusText}`
|
|
33408
|
-
);
|
|
33409
|
-
}
|
|
33410
|
-
return DataFileEnvelopeSchema.parse(await response.json());
|
|
33411
|
-
}
|
|
33412
|
-
|
|
33413
33220
|
// src/protocol/gateway.ts
|
|
33414
33221
|
function createGatewayClient(baseUrl) {
|
|
33415
33222
|
const base = baseUrl.replace(/\/+$/, "");
|
|
@@ -33417,6 +33224,16 @@ function createGatewayClient(baseUrl) {
|
|
|
33417
33224
|
const envelope = await res.json();
|
|
33418
33225
|
return envelope.data;
|
|
33419
33226
|
}
|
|
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
|
+
}
|
|
33420
33237
|
function getMutationId(body, key) {
|
|
33421
33238
|
const value = body[key] ?? body["id"];
|
|
33422
33239
|
return typeof value === "string" ? value : void 0;
|
|
@@ -33466,33 +33283,31 @@ function createGatewayClient(baseUrl) {
|
|
|
33466
33283
|
}
|
|
33467
33284
|
return unwrapEnvelope(res);
|
|
33468
33285
|
},
|
|
33469
|
-
async
|
|
33470
|
-
const res = await fetch(`${base}/v1/
|
|
33286
|
+
async getFile(fileId) {
|
|
33287
|
+
const res = await fetch(`${base}/v1/files/${fileId}`);
|
|
33471
33288
|
if (res.status === 404) return null;
|
|
33472
33289
|
if (!res.ok) {
|
|
33473
33290
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33474
33291
|
}
|
|
33475
|
-
return unwrapEnvelope(res);
|
|
33292
|
+
return normalizeFileRecord(await unwrapEnvelope(res));
|
|
33476
33293
|
},
|
|
33477
|
-
async
|
|
33294
|
+
async listFilesSince(owner, cursor, options) {
|
|
33478
33295
|
const params = new URLSearchParams({ user: owner });
|
|
33479
33296
|
if (cursor !== null) {
|
|
33480
33297
|
params.set("cursor", cursor);
|
|
33481
33298
|
}
|
|
33482
|
-
if (options?.
|
|
33483
|
-
params.set("
|
|
33299
|
+
if (options?.includeDeleted) {
|
|
33300
|
+
params.set("includeDeleted", "true");
|
|
33484
33301
|
}
|
|
33485
|
-
|
|
33486
|
-
params.set("limit", String(options.limit));
|
|
33487
|
-
}
|
|
33488
|
-
const res = await fetch(`${base}/v1/data?${params.toString()}`);
|
|
33302
|
+
const res = await fetch(`${base}/v1/files?${params.toString()}`);
|
|
33489
33303
|
if (!res.ok) {
|
|
33490
33304
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33491
33305
|
}
|
|
33492
33306
|
const envelope = await res.json();
|
|
33493
|
-
const
|
|
33307
|
+
const { pagination } = envelope;
|
|
33308
|
+
const nextCursor = pagination?.hasMore === false ? null : pagination?.nextCursor ?? envelope.data.cursor ?? null;
|
|
33494
33309
|
return {
|
|
33495
|
-
|
|
33310
|
+
files: envelope.data.files.map(normalizeFileRecord),
|
|
33496
33311
|
cursor: nextCursor
|
|
33497
33312
|
};
|
|
33498
33313
|
},
|
|
@@ -33534,8 +33349,8 @@ function createGatewayClient(baseUrl) {
|
|
|
33534
33349
|
alreadyRegistered: false
|
|
33535
33350
|
};
|
|
33536
33351
|
},
|
|
33537
|
-
async
|
|
33538
|
-
const res = await fetch(`${base}/v1/
|
|
33352
|
+
async registerFile(params) {
|
|
33353
|
+
const res = await fetch(`${base}/v1/files`, {
|
|
33539
33354
|
method: "POST",
|
|
33540
33355
|
headers: {
|
|
33541
33356
|
"Content-Type": "application/json",
|
|
@@ -33543,57 +33358,22 @@ function createGatewayClient(baseUrl) {
|
|
|
33543
33358
|
},
|
|
33544
33359
|
body: JSON.stringify({
|
|
33545
33360
|
ownerAddress: params.ownerAddress,
|
|
33546
|
-
|
|
33547
|
-
|
|
33548
|
-
appUrl: params.appUrl
|
|
33361
|
+
url: params.url,
|
|
33362
|
+
schemaId: params.schemaId
|
|
33549
33363
|
})
|
|
33550
33364
|
});
|
|
33551
33365
|
if (res.status === 409) {
|
|
33552
33366
|
const body2 = await res.json().catch(() => ({}));
|
|
33553
33367
|
return {
|
|
33554
|
-
|
|
33555
|
-
body2,
|
|
33556
|
-
"builderId"
|
|
33557
|
-
),
|
|
33558
|
-
alreadyRegistered: true
|
|
33368
|
+
fileId: getMutationId(body2, "fileId")
|
|
33559
33369
|
};
|
|
33560
33370
|
}
|
|
33561
33371
|
if (!res.ok) {
|
|
33562
33372
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33563
33373
|
}
|
|
33564
|
-
const body = await res.json()
|
|
33565
|
-
return {
|
|
33566
|
-
builderId: getMutationId(body, "builderId"),
|
|
33567
|
-
alreadyRegistered: false
|
|
33568
|
-
};
|
|
33569
|
-
},
|
|
33570
|
-
async registerDataPoint(params) {
|
|
33571
|
-
const res = await fetch(`${base}/v1/data`, {
|
|
33572
|
-
method: "POST",
|
|
33573
|
-
headers: {
|
|
33574
|
-
"Content-Type": "application/json",
|
|
33575
|
-
Authorization: `Web3Signed ${params.signature}`
|
|
33576
|
-
},
|
|
33577
|
-
body: JSON.stringify({
|
|
33578
|
-
ownerAddress: params.ownerAddress,
|
|
33579
|
-
scope: params.scope,
|
|
33580
|
-
dataHash: params.dataHash,
|
|
33581
|
-
metadataHash: params.metadataHash,
|
|
33582
|
-
expectedVersion: params.expectedVersion
|
|
33583
|
-
})
|
|
33584
|
-
});
|
|
33585
|
-
if (!res.ok) {
|
|
33586
|
-
const body2 = await res.json().catch(() => ({}));
|
|
33587
|
-
const detail = body2.error ?? res.statusText;
|
|
33588
|
-
throw new Error(`Gateway error: ${res.status} ${detail}`);
|
|
33589
|
-
}
|
|
33590
|
-
const body = await res.json().catch(() => ({}));
|
|
33374
|
+
const body = await res.json();
|
|
33591
33375
|
return {
|
|
33592
|
-
|
|
33593
|
-
body,
|
|
33594
|
-
"dataPointId"
|
|
33595
|
-
),
|
|
33596
|
-
expectedVersion: body.expectedVersion
|
|
33376
|
+
fileId: getMutationId(body, "fileId")
|
|
33597
33377
|
};
|
|
33598
33378
|
},
|
|
33599
33379
|
async createGrant(params) {
|
|
@@ -33606,9 +33386,8 @@ function createGatewayClient(baseUrl) {
|
|
|
33606
33386
|
body: JSON.stringify({
|
|
33607
33387
|
grantorAddress: params.grantorAddress,
|
|
33608
33388
|
granteeId: params.granteeId,
|
|
33609
|
-
|
|
33610
|
-
|
|
33611
|
-
expiresAt: params.expiresAt
|
|
33389
|
+
grant: params.grant,
|
|
33390
|
+
fileIds: params.fileIds
|
|
33612
33391
|
})
|
|
33613
33392
|
});
|
|
33614
33393
|
if (res.status === 409) {
|
|
@@ -33633,8 +33412,7 @@ function createGatewayClient(baseUrl) {
|
|
|
33633
33412
|
Authorization: `Web3Signed ${params.signature}`
|
|
33634
33413
|
},
|
|
33635
33414
|
body: JSON.stringify({
|
|
33636
|
-
grantorAddress: params.grantorAddress
|
|
33637
|
-
grantVersion: params.grantVersion
|
|
33415
|
+
grantorAddress: params.grantorAddress
|
|
33638
33416
|
})
|
|
33639
33417
|
});
|
|
33640
33418
|
if (res.status === 409) return;
|
|
@@ -33642,62 +33420,133 @@ function createGatewayClient(baseUrl) {
|
|
|
33642
33420
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33643
33421
|
}
|
|
33644
33422
|
},
|
|
33645
|
-
async
|
|
33646
|
-
const res = await fetch(`${base}/v1/
|
|
33423
|
+
async deleteFile(params) {
|
|
33424
|
+
const res = await fetch(`${base}/v1/files/${params.fileId}`, {
|
|
33425
|
+
method: "DELETE",
|
|
33426
|
+
headers: {
|
|
33427
|
+
"Content-Type": "application/json",
|
|
33428
|
+
Authorization: `Web3Signed ${params.signature}`
|
|
33429
|
+
},
|
|
33430
|
+
body: JSON.stringify({
|
|
33431
|
+
ownerAddress: params.ownerAddress
|
|
33432
|
+
})
|
|
33433
|
+
});
|
|
33434
|
+
if (res.status === 409) return;
|
|
33647
33435
|
if (!res.ok) {
|
|
33648
33436
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33649
33437
|
}
|
|
33650
|
-
|
|
33651
|
-
|
|
33652
|
-
|
|
33438
|
+
}
|
|
33439
|
+
};
|
|
33440
|
+
}
|
|
33441
|
+
|
|
33442
|
+
// src/protocol/escrow.ts
|
|
33443
|
+
var GENERIC_PAYMENT_TYPES = {
|
|
33444
|
+
GenericPayment: [
|
|
33445
|
+
{ name: "payerAddress", type: "address" },
|
|
33446
|
+
{ name: "opType", type: "string" },
|
|
33447
|
+
{ name: "opId", type: "bytes32" },
|
|
33448
|
+
{ name: "asset", type: "address" },
|
|
33449
|
+
{ name: "amount", type: "uint256" },
|
|
33450
|
+
{ name: "paymentNonce", type: "uint256" }
|
|
33451
|
+
]
|
|
33452
|
+
};
|
|
33453
|
+
function genericPaymentDomain(chainId, escrowContract) {
|
|
33454
|
+
return {
|
|
33455
|
+
name: "Vana Data Portability",
|
|
33456
|
+
version: "1",
|
|
33457
|
+
chainId,
|
|
33458
|
+
verifyingContract: escrowContract
|
|
33459
|
+
};
|
|
33460
|
+
}
|
|
33461
|
+
var ESCROW_DEPOSIT_ABI = [
|
|
33462
|
+
{
|
|
33463
|
+
type: "function",
|
|
33464
|
+
name: "depositNative",
|
|
33465
|
+
stateMutability: "payable",
|
|
33466
|
+
inputs: [{ name: "account", type: "address" }],
|
|
33467
|
+
outputs: []
|
|
33468
|
+
},
|
|
33469
|
+
{
|
|
33470
|
+
type: "function",
|
|
33471
|
+
name: "depositToken",
|
|
33472
|
+
stateMutability: "nonpayable",
|
|
33473
|
+
inputs: [
|
|
33474
|
+
{ name: "account", type: "address" },
|
|
33475
|
+
{ name: "token", type: "address" },
|
|
33476
|
+
{ name: "amount", type: "uint256" }
|
|
33477
|
+
],
|
|
33478
|
+
outputs: []
|
|
33479
|
+
}
|
|
33480
|
+
];
|
|
33481
|
+
var NATIVE_ASSET_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
33482
|
+
function createEscrowGatewayClient(baseUrl) {
|
|
33483
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
33484
|
+
async function throwOnError(res, context) {
|
|
33485
|
+
if (!res.ok) {
|
|
33486
|
+
let detail = "";
|
|
33487
|
+
try {
|
|
33488
|
+
const body = await res.json();
|
|
33489
|
+
if (body.error) detail = `: ${body.error}`;
|
|
33490
|
+
} catch {
|
|
33491
|
+
}
|
|
33492
|
+
throw new Error(
|
|
33493
|
+
`Escrow gateway error (${context}): ${res.status} ${res.statusText}${detail}`
|
|
33494
|
+
);
|
|
33495
|
+
}
|
|
33496
|
+
}
|
|
33497
|
+
return {
|
|
33498
|
+
async submitDeposit({ txHash }) {
|
|
33653
33499
|
const res = await fetch(`${base}/v1/escrow/deposit`, {
|
|
33654
33500
|
method: "POST",
|
|
33655
33501
|
headers: { "Content-Type": "application/json" },
|
|
33656
|
-
body: JSON.stringify({ txHash
|
|
33502
|
+
body: JSON.stringify({ txHash })
|
|
33657
33503
|
});
|
|
33658
33504
|
if (res.status !== 200 && res.status !== 202) {
|
|
33659
|
-
|
|
33505
|
+
await throwOnError(res, "POST /v1/escrow/deposit");
|
|
33660
33506
|
}
|
|
33661
|
-
return
|
|
33507
|
+
return res.json();
|
|
33662
33508
|
},
|
|
33663
|
-
async
|
|
33664
|
-
const
|
|
33665
|
-
|
|
33666
|
-
|
|
33667
|
-
|
|
33668
|
-
|
|
33669
|
-
|
|
33670
|
-
|
|
33671
|
-
|
|
33672
|
-
|
|
33673
|
-
|
|
33674
|
-
|
|
33509
|
+
async getEscrowBalance(account) {
|
|
33510
|
+
const res = await fetch(
|
|
33511
|
+
`${base}/v1/escrow/balance?account=${encodeURIComponent(account)}`
|
|
33512
|
+
);
|
|
33513
|
+
await throwOnError(res, "GET /v1/escrow/balance");
|
|
33514
|
+
return res.json();
|
|
33515
|
+
},
|
|
33516
|
+
async syncEscrowBalance(account) {
|
|
33517
|
+
const res = await fetch(
|
|
33518
|
+
`${base}/v1/escrow/balance/sync?account=${encodeURIComponent(account)}`,
|
|
33519
|
+
{ method: "POST" }
|
|
33520
|
+
);
|
|
33521
|
+
await throwOnError(res, "POST /v1/escrow/balance/sync");
|
|
33522
|
+
return res.json();
|
|
33523
|
+
},
|
|
33524
|
+
async payForOp({
|
|
33525
|
+
payerAddress,
|
|
33526
|
+
opType,
|
|
33527
|
+
opId,
|
|
33528
|
+
asset,
|
|
33529
|
+
amount,
|
|
33530
|
+
paymentNonce,
|
|
33531
|
+
signature
|
|
33532
|
+
}) {
|
|
33675
33533
|
const res = await fetch(`${base}/v1/escrow/pay`, {
|
|
33676
33534
|
method: "POST",
|
|
33677
33535
|
headers: {
|
|
33678
33536
|
"Content-Type": "application/json",
|
|
33679
|
-
Authorization: `Web3Signed ${
|
|
33537
|
+
Authorization: `Web3Signed ${signature}`
|
|
33680
33538
|
},
|
|
33681
|
-
body: JSON.stringify(
|
|
33682
|
-
|
|
33683
|
-
|
|
33684
|
-
|
|
33685
|
-
|
|
33686
|
-
|
|
33687
|
-
|
|
33688
|
-
|
|
33689
|
-
const res = await fetch(`${base}/v1/settle`, {
|
|
33690
|
-
method: "POST",
|
|
33691
|
-
headers: { "Content-Type": "application/json" },
|
|
33692
|
-
// The gateway accepts an empty body; only `limit` is recognised.
|
|
33693
|
-
// Always send a JSON body so the gateway's req.body shape parse
|
|
33694
|
-
// doesn't have to deal with an undefined.
|
|
33695
|
-
body: JSON.stringify(params ?? {})
|
|
33539
|
+
body: JSON.stringify({
|
|
33540
|
+
payerAddress,
|
|
33541
|
+
opType,
|
|
33542
|
+
opId,
|
|
33543
|
+
asset,
|
|
33544
|
+
amount,
|
|
33545
|
+
paymentNonce
|
|
33546
|
+
})
|
|
33696
33547
|
});
|
|
33697
|
-
|
|
33698
|
-
|
|
33699
|
-
}
|
|
33700
|
-
return await res.json();
|
|
33548
|
+
await throwOnError(res, "POST /v1/escrow/pay");
|
|
33549
|
+
return res.json();
|
|
33701
33550
|
}
|
|
33702
33551
|
};
|
|
33703
33552
|
}
|
|
@@ -33766,7 +33615,6 @@ async function parsePSError(response) {
|
|
|
33766
33615
|
}
|
|
33767
33616
|
export {
|
|
33768
33617
|
ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
|
|
33769
|
-
ADD_DATA_TYPES,
|
|
33770
33618
|
AccountPersonalServerLiteOwnerBindingError,
|
|
33771
33619
|
AccountPersonalServerRegistrationError,
|
|
33772
33620
|
BUILDER_REGISTRATION_TYPES,
|
|
@@ -33776,14 +33624,13 @@ export {
|
|
|
33776
33624
|
CallbackStorage,
|
|
33777
33625
|
ContractFactory,
|
|
33778
33626
|
ContractNotFoundError,
|
|
33779
|
-
DATA_REGISTRY_STATUS_ABI,
|
|
33780
33627
|
DataFileEnvelopeSchema,
|
|
33781
|
-
DataPointStatus,
|
|
33782
33628
|
DropboxStorage,
|
|
33783
33629
|
ECIESError,
|
|
33784
33630
|
ESCROW_DEPOSIT_ABI,
|
|
33785
33631
|
ExpiredTokenError,
|
|
33786
|
-
|
|
33632
|
+
FILE_DELETION_TYPES,
|
|
33633
|
+
FILE_REGISTRATION_TYPES,
|
|
33787
33634
|
GENERIC_PAYMENT_TYPES,
|
|
33788
33635
|
GRANT_REGISTRATION_TYPES,
|
|
33789
33636
|
GRANT_REVOCATION_TYPES,
|
|
@@ -33795,7 +33642,7 @@ export {
|
|
|
33795
33642
|
IpfsStorage,
|
|
33796
33643
|
MASTER_KEY_MESSAGE,
|
|
33797
33644
|
MissingAuthError,
|
|
33798
|
-
|
|
33645
|
+
NATIVE_ASSET_ADDRESS,
|
|
33799
33646
|
NetworkError,
|
|
33800
33647
|
NodeECIESUint8Provider as NodeECIESProvider,
|
|
33801
33648
|
NodePlatformAdapter,
|
|
@@ -33813,8 +33660,6 @@ export {
|
|
|
33813
33660
|
PersonalServerError,
|
|
33814
33661
|
PinataStorage,
|
|
33815
33662
|
R2Storage,
|
|
33816
|
-
RECORD_DATA_ACCESS_TYPES,
|
|
33817
|
-
REGISTRATION_KIND_FOR_OP,
|
|
33818
33663
|
ReadOnlyError,
|
|
33819
33664
|
RelayerError,
|
|
33820
33665
|
SERVER_REGISTRATION_TYPES,
|
|
@@ -33829,15 +33674,10 @@ export {
|
|
|
33829
33674
|
VanaError,
|
|
33830
33675
|
VanaStorage,
|
|
33831
33676
|
assertValidPkceVerifier,
|
|
33832
|
-
buildDepositNativeRequest,
|
|
33833
|
-
buildDepositTokenRequest,
|
|
33834
|
-
buildMarkDataPointUnavailableRequest,
|
|
33835
|
-
buildPersonalServerDataReadRequest,
|
|
33836
33677
|
buildPersonalServerLiteOwnerBindingMessage,
|
|
33837
33678
|
buildPersonalServerLiteOwnerBindingSignature,
|
|
33838
33679
|
buildPersonalServerRegistrationSignature,
|
|
33839
33680
|
buildPersonalServerRegistrationTypedData,
|
|
33840
|
-
buildSetDataPointStatusRequest,
|
|
33841
33681
|
buildWeb3SignedHeader,
|
|
33842
33682
|
builderRegistrationDomain,
|
|
33843
33683
|
chains,
|
|
@@ -33847,6 +33687,7 @@ export {
|
|
|
33847
33687
|
contractCacheForTesting,
|
|
33848
33688
|
createBrowserPlatformAdapter,
|
|
33849
33689
|
createDataFileEnvelope,
|
|
33690
|
+
createEscrowGatewayClient,
|
|
33850
33691
|
createGatewayClient,
|
|
33851
33692
|
createNodePlatformAdapter,
|
|
33852
33693
|
createPlatformAdapter,
|
|
@@ -33855,28 +33696,22 @@ export {
|
|
|
33855
33696
|
createVanaStorageProvider,
|
|
33856
33697
|
createViemPersonalServerLiteOwnerBindingSigner,
|
|
33857
33698
|
createViemPersonalServerRegistrationSigner,
|
|
33858
|
-
dataRegistryContractAddress,
|
|
33859
|
-
dataRegistryDomain,
|
|
33860
33699
|
decryptWithPassword,
|
|
33861
33700
|
deriveMasterKey,
|
|
33862
33701
|
deriveScopeKey,
|
|
33863
33702
|
deserializeECIES,
|
|
33864
33703
|
detectPlatform,
|
|
33865
|
-
encodeDepositNativeData,
|
|
33866
|
-
encodeDepositTokenData,
|
|
33867
|
-
encodeSetDataPointStatusData,
|
|
33868
33704
|
encryptWithPassword,
|
|
33869
|
-
|
|
33870
|
-
|
|
33705
|
+
fileDeletionDomain,
|
|
33706
|
+
fileRegistrationDomain,
|
|
33871
33707
|
generatePkceVerifier,
|
|
33708
|
+
genericPaymentDomain,
|
|
33872
33709
|
getAbi,
|
|
33873
33710
|
getAllChains,
|
|
33874
33711
|
getChainConfig,
|
|
33875
33712
|
getContractAddress,
|
|
33876
33713
|
getContractController,
|
|
33877
33714
|
getContractInfo,
|
|
33878
|
-
getFee,
|
|
33879
|
-
getOpFee,
|
|
33880
33715
|
getPlatformCapabilities,
|
|
33881
33716
|
getServiceEndpoints,
|
|
33882
33717
|
grantRegistrationDomain,
|
|
@@ -33888,12 +33723,11 @@ export {
|
|
|
33888
33723
|
moksha,
|
|
33889
33724
|
mokshaServices,
|
|
33890
33725
|
mokshaTestnet2 as mokshaTestnet,
|
|
33726
|
+
parseGrantRegistrationPayload,
|
|
33891
33727
|
parsePSError,
|
|
33892
33728
|
parseScope,
|
|
33893
33729
|
parseWeb3SignedHeader,
|
|
33894
|
-
personalServerDataReadPath,
|
|
33895
33730
|
personalServerRegistrationDomain,
|
|
33896
|
-
readPersonalServerData,
|
|
33897
33731
|
recoverServerOwner,
|
|
33898
33732
|
registerPersonalServerSignature,
|
|
33899
33733
|
scopeCoveredByGrant,
|