@opendatalabs/vana-sdk 0.1.0-alpha.6b821f9 → 0.1.0-alpha.71a61ac
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 +30 -11
- package/dist/index.browser.js +68 -26
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +76 -27
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.cts +30 -11
- package/dist/index.node.d.ts +30 -11
- package/dist/index.node.js +76 -27
- package/dist/index.node.js.map +1 -1
- package/package.json +1 -1
package/dist/index.browser.d.ts
CHANGED
|
@@ -634,8 +634,6 @@ interface ServerInfo {
|
|
|
634
634
|
* @category Permissions
|
|
635
635
|
*/
|
|
636
636
|
interface AddAndTrustServerParams {
|
|
637
|
-
/** Server owner address */
|
|
638
|
-
owner: Address;
|
|
639
637
|
/** Server address */
|
|
640
638
|
serverAddress: Address;
|
|
641
639
|
/** Server URL */
|
|
@@ -670,8 +668,6 @@ interface UntrustServerParams {
|
|
|
670
668
|
interface AddAndTrustServerInput {
|
|
671
669
|
/** User nonce */
|
|
672
670
|
nonce: bigint;
|
|
673
|
-
/** Server owner address */
|
|
674
|
-
owner: Address;
|
|
675
671
|
/** Server address */
|
|
676
672
|
serverAddress: Address;
|
|
677
673
|
/** Server URL */
|
|
@@ -712,13 +708,13 @@ interface AddAndTrustServerTypedData {
|
|
|
712
708
|
domain: PermissionGrantDomain;
|
|
713
709
|
/** EIP-712 types */
|
|
714
710
|
types: {
|
|
715
|
-
|
|
711
|
+
AddServer: Array<{
|
|
716
712
|
name: string;
|
|
717
713
|
type: string;
|
|
718
714
|
}>;
|
|
719
715
|
};
|
|
720
716
|
/** Primary type */
|
|
721
|
-
primaryType: "
|
|
717
|
+
primaryType: "AddServer";
|
|
722
718
|
/** Message to sign */
|
|
723
719
|
message: AddAndTrustServerInput;
|
|
724
720
|
}
|
|
@@ -30031,7 +30027,10 @@ declare class PermissionsController {
|
|
|
30031
30027
|
*/
|
|
30032
30028
|
submitRevokeWithSignature(params: RevokePermissionParams): Promise<Hash>;
|
|
30033
30029
|
/**
|
|
30030
|
+
* @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
|
|
30031
|
+
*
|
|
30034
30032
|
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
30033
|
+
* This method is deprecated in favor of more specific nonce methods.
|
|
30035
30034
|
*
|
|
30036
30035
|
* The nonce is used to prevent replay attacks in signed transactions and must
|
|
30037
30036
|
* be incremented with each transaction to maintain security.
|
|
@@ -30043,8 +30042,12 @@ declare class PermissionsController {
|
|
|
30043
30042
|
* @private
|
|
30044
30043
|
* @example
|
|
30045
30044
|
* ```typescript
|
|
30045
|
+
* // Deprecated - use specific methods instead
|
|
30046
30046
|
* const nonce = await this.getUserNonce();
|
|
30047
|
-
*
|
|
30047
|
+
*
|
|
30048
|
+
* // Use these instead:
|
|
30049
|
+
* const permissionsNonce = await this.getPermissionsUserNonce();
|
|
30050
|
+
* const serversNonce = await this.getServersUserNonce();
|
|
30048
30051
|
* ```
|
|
30049
30052
|
*/
|
|
30050
30053
|
private getUserNonce;
|
|
@@ -30052,16 +30055,32 @@ declare class PermissionsController {
|
|
|
30052
30055
|
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
30053
30056
|
* This nonce is used for server-related operations (AddAndTrustServer, TrustServer, UntrustServer).
|
|
30054
30057
|
*
|
|
30055
|
-
* @returns Promise resolving to the current nonce
|
|
30058
|
+
* @returns Promise resolving to the current servers nonce
|
|
30059
|
+
* @throws {NonceError} When reading nonce from contract fails
|
|
30060
|
+
* @private
|
|
30061
|
+
*
|
|
30062
|
+
* @example
|
|
30063
|
+
* ```typescript
|
|
30064
|
+
* const nonce = await this.getServersUserNonce();
|
|
30065
|
+
* console.log(`Current servers nonce: ${nonce}`);
|
|
30066
|
+
* ```
|
|
30067
|
+
*/
|
|
30068
|
+
private getServersUserNonce;
|
|
30069
|
+
/**
|
|
30070
|
+
* Retrieves the user's current nonce from the DataPortabilityPermissions contract.
|
|
30071
|
+
* This nonce is used for permission-related operations (addPermission, addServerFilesAndPermissions).
|
|
30072
|
+
*
|
|
30073
|
+
* @returns Promise resolving to the current permissions nonce
|
|
30074
|
+
* @throws {NonceError} When reading nonce from contract fails
|
|
30056
30075
|
* @private
|
|
30057
30076
|
*
|
|
30058
30077
|
* @example
|
|
30059
30078
|
* ```typescript
|
|
30060
|
-
* const nonce = await this.
|
|
30061
|
-
* console.log(`Current
|
|
30079
|
+
* const nonce = await this.getPermissionsUserNonce();
|
|
30080
|
+
* console.log(`Current permissions nonce: ${nonce}`);
|
|
30062
30081
|
* ```
|
|
30063
30082
|
*/
|
|
30064
|
-
private
|
|
30083
|
+
private getPermissionsUserNonce;
|
|
30065
30084
|
/**
|
|
30066
30085
|
* Composes the EIP-712 typed data for PermissionGrant (new simplified format).
|
|
30067
30086
|
*
|
package/dist/index.browser.js
CHANGED
|
@@ -36250,7 +36250,7 @@ var PermissionsController = class {
|
|
|
36250
36250
|
throw new Error("Failed to store grant file - no URL returned");
|
|
36251
36251
|
}
|
|
36252
36252
|
}
|
|
36253
|
-
const nonce = await this.
|
|
36253
|
+
const nonce = await this.getPermissionsUserNonce();
|
|
36254
36254
|
console.debug(
|
|
36255
36255
|
"\u{1F50D} Debug - Final grant URL being passed to compose:",
|
|
36256
36256
|
grantUrl
|
|
@@ -36343,7 +36343,7 @@ var PermissionsController = class {
|
|
|
36343
36343
|
throw new Error("Failed to store grant file - no URL returned");
|
|
36344
36344
|
}
|
|
36345
36345
|
}
|
|
36346
|
-
const nonce = await this.
|
|
36346
|
+
const nonce = await this.getPermissionsUserNonce();
|
|
36347
36347
|
console.debug(
|
|
36348
36348
|
"\u{1F50D} Debug - Final grant URL being passed to compose:",
|
|
36349
36349
|
grantUrl
|
|
@@ -36485,7 +36485,6 @@ var PermissionsController = class {
|
|
|
36485
36485
|
try {
|
|
36486
36486
|
const addAndTrustServerInput = {
|
|
36487
36487
|
nonce: BigInt(typedData.message.nonce),
|
|
36488
|
-
owner: typedData.message.owner,
|
|
36489
36488
|
serverAddress: typedData.message.serverAddress,
|
|
36490
36489
|
serverUrl: typedData.message.serverUrl,
|
|
36491
36490
|
publicKey: typedData.message.publicKey
|
|
@@ -36499,7 +36498,7 @@ var PermissionsController = class {
|
|
|
36499
36498
|
throw error;
|
|
36500
36499
|
}
|
|
36501
36500
|
throw new BlockchainError(
|
|
36502
|
-
`Add and trust server submission
|
|
36501
|
+
`Add and trust server submission failed444444: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
36503
36502
|
error
|
|
36504
36503
|
);
|
|
36505
36504
|
}
|
|
@@ -36704,7 +36703,7 @@ var PermissionsController = class {
|
|
|
36704
36703
|
if (!this.context.walletClient.chain?.id) {
|
|
36705
36704
|
throw new BlockchainError("Chain ID not available");
|
|
36706
36705
|
}
|
|
36707
|
-
const nonce = await this.
|
|
36706
|
+
const nonce = await this.getPermissionsUserNonce();
|
|
36708
36707
|
const revokePermissionInput = {
|
|
36709
36708
|
nonce,
|
|
36710
36709
|
permissionId: params.permissionId
|
|
@@ -36737,7 +36736,10 @@ var PermissionsController = class {
|
|
|
36737
36736
|
}
|
|
36738
36737
|
}
|
|
36739
36738
|
/**
|
|
36739
|
+
* @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
|
|
36740
|
+
*
|
|
36740
36741
|
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
36742
|
+
* This method is deprecated in favor of more specific nonce methods.
|
|
36741
36743
|
*
|
|
36742
36744
|
* The nonce is used to prevent replay attacks in signed transactions and must
|
|
36743
36745
|
* be incremented with each transaction to maintain security.
|
|
@@ -36749,8 +36751,12 @@ var PermissionsController = class {
|
|
|
36749
36751
|
* @private
|
|
36750
36752
|
* @example
|
|
36751
36753
|
* ```typescript
|
|
36754
|
+
* // Deprecated - use specific methods instead
|
|
36752
36755
|
* const nonce = await this.getUserNonce();
|
|
36753
|
-
*
|
|
36756
|
+
*
|
|
36757
|
+
* // Use these instead:
|
|
36758
|
+
* const permissionsNonce = await this.getPermissionsUserNonce();
|
|
36759
|
+
* const serversNonce = await this.getServersUserNonce();
|
|
36754
36760
|
* ```
|
|
36755
36761
|
*/
|
|
36756
36762
|
async getUserNonce() {
|
|
@@ -36779,16 +36785,17 @@ var PermissionsController = class {
|
|
|
36779
36785
|
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
36780
36786
|
* This nonce is used for server-related operations (AddAndTrustServer, TrustServer, UntrustServer).
|
|
36781
36787
|
*
|
|
36782
|
-
* @returns Promise resolving to the current nonce
|
|
36788
|
+
* @returns Promise resolving to the current servers nonce
|
|
36789
|
+
* @throws {NonceError} When reading nonce from contract fails
|
|
36783
36790
|
* @private
|
|
36784
36791
|
*
|
|
36785
36792
|
* @example
|
|
36786
36793
|
* ```typescript
|
|
36787
|
-
* const nonce = await this.
|
|
36788
|
-
* console.log(`Current
|
|
36794
|
+
* const nonce = await this.getServersUserNonce();
|
|
36795
|
+
* console.log(`Current servers nonce: ${nonce}`);
|
|
36789
36796
|
* ```
|
|
36790
36797
|
*/
|
|
36791
|
-
async
|
|
36798
|
+
async getServersUserNonce() {
|
|
36792
36799
|
try {
|
|
36793
36800
|
const userAddress = await this.getUserAddress();
|
|
36794
36801
|
const chainId = await this.context.walletClient.getChainId();
|
|
@@ -36810,6 +36817,44 @@ var PermissionsController = class {
|
|
|
36810
36817
|
);
|
|
36811
36818
|
}
|
|
36812
36819
|
}
|
|
36820
|
+
/**
|
|
36821
|
+
* Retrieves the user's current nonce from the DataPortabilityPermissions contract.
|
|
36822
|
+
* This nonce is used for permission-related operations (addPermission, addServerFilesAndPermissions).
|
|
36823
|
+
*
|
|
36824
|
+
* @returns Promise resolving to the current permissions nonce
|
|
36825
|
+
* @throws {NonceError} When reading nonce from contract fails
|
|
36826
|
+
* @private
|
|
36827
|
+
*
|
|
36828
|
+
* @example
|
|
36829
|
+
* ```typescript
|
|
36830
|
+
* const nonce = await this.getPermissionsUserNonce();
|
|
36831
|
+
* console.log(`Current permissions nonce: ${nonce}`);
|
|
36832
|
+
* ```
|
|
36833
|
+
*/
|
|
36834
|
+
async getPermissionsUserNonce() {
|
|
36835
|
+
try {
|
|
36836
|
+
const userAddress = await this.getUserAddress();
|
|
36837
|
+
const chainId = await this.context.walletClient.getChainId();
|
|
36838
|
+
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
36839
|
+
chainId,
|
|
36840
|
+
"DataPortabilityPermissions"
|
|
36841
|
+
);
|
|
36842
|
+
const DataPortabilityPermissionsAbi = getAbi(
|
|
36843
|
+
"DataPortabilityPermissions"
|
|
36844
|
+
);
|
|
36845
|
+
const nonce = await this.context.publicClient.readContract({
|
|
36846
|
+
address: DataPortabilityPermissionsAddress,
|
|
36847
|
+
abi: DataPortabilityPermissionsAbi,
|
|
36848
|
+
functionName: "userNonce",
|
|
36849
|
+
args: [userAddress]
|
|
36850
|
+
});
|
|
36851
|
+
return nonce;
|
|
36852
|
+
} catch (error) {
|
|
36853
|
+
throw new NonceError(
|
|
36854
|
+
`Failed to retrieve permissions nonce: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
36855
|
+
);
|
|
36856
|
+
}
|
|
36857
|
+
}
|
|
36813
36858
|
/**
|
|
36814
36859
|
* Composes the EIP-712 typed data for PermissionGrant (new simplified format).
|
|
36815
36860
|
*
|
|
@@ -37171,12 +37216,13 @@ var PermissionsController = class {
|
|
|
37171
37216
|
"DataPortabilityServers"
|
|
37172
37217
|
);
|
|
37173
37218
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
37219
|
+
const userAddress = this.context.walletClient.account?.address || await this.getUserAddress();
|
|
37174
37220
|
const txHash = await this.context.walletClient.writeContract({
|
|
37175
37221
|
address: DataPortabilityServersAddress,
|
|
37176
37222
|
abi: DataPortabilityServersAbi,
|
|
37177
37223
|
functionName: "addAndTrustServerOnBehalf",
|
|
37178
37224
|
args: [
|
|
37179
|
-
|
|
37225
|
+
userAddress,
|
|
37180
37226
|
{
|
|
37181
37227
|
serverAddress: params.serverAddress,
|
|
37182
37228
|
serverUrl: params.serverUrl,
|
|
@@ -37239,10 +37285,9 @@ var PermissionsController = class {
|
|
|
37239
37285
|
*/
|
|
37240
37286
|
async submitAddAndTrustServerWithSignature(params) {
|
|
37241
37287
|
try {
|
|
37242
|
-
const nonce = await this.
|
|
37288
|
+
const nonce = await this.getServersUserNonce();
|
|
37243
37289
|
const addAndTrustServerInput = {
|
|
37244
37290
|
nonce,
|
|
37245
|
-
owner: params.owner,
|
|
37246
37291
|
serverAddress: params.serverAddress,
|
|
37247
37292
|
publicKey: params.publicKey,
|
|
37248
37293
|
serverUrl: params.serverUrl
|
|
@@ -37252,7 +37297,6 @@ var PermissionsController = class {
|
|
|
37252
37297
|
);
|
|
37253
37298
|
console.debug("\u{1F50D} AddAndTrustServer Debug Info:", {
|
|
37254
37299
|
nonce: nonce.toString(),
|
|
37255
|
-
owner: params.owner,
|
|
37256
37300
|
serverAddress: params.serverAddress,
|
|
37257
37301
|
publicKey: params.publicKey,
|
|
37258
37302
|
serverUrl: params.serverUrl,
|
|
@@ -37304,7 +37348,7 @@ var PermissionsController = class {
|
|
|
37304
37348
|
*/
|
|
37305
37349
|
async submitTrustServerWithSignature(params) {
|
|
37306
37350
|
try {
|
|
37307
|
-
const nonce = await this.
|
|
37351
|
+
const nonce = await this.getServersUserNonce();
|
|
37308
37352
|
const trustServerInput = {
|
|
37309
37353
|
nonce,
|
|
37310
37354
|
serverId: params.serverId
|
|
@@ -37399,7 +37443,7 @@ var PermissionsController = class {
|
|
|
37399
37443
|
* ```
|
|
37400
37444
|
*/
|
|
37401
37445
|
async submitUntrustServer(params) {
|
|
37402
|
-
const nonce = await this.
|
|
37446
|
+
const nonce = await this.getServersUserNonce();
|
|
37403
37447
|
const untrustServerInput = {
|
|
37404
37448
|
nonce,
|
|
37405
37449
|
serverId: params.serverId
|
|
@@ -37420,7 +37464,7 @@ var PermissionsController = class {
|
|
|
37420
37464
|
*/
|
|
37421
37465
|
async submitUntrustServerWithSignature(params) {
|
|
37422
37466
|
try {
|
|
37423
|
-
const nonce = await this.
|
|
37467
|
+
const nonce = await this.getServersUserNonce();
|
|
37424
37468
|
const untrustServerInput = {
|
|
37425
37469
|
nonce,
|
|
37426
37470
|
serverId: params.serverId
|
|
@@ -37728,18 +37772,18 @@ var PermissionsController = class {
|
|
|
37728
37772
|
*/
|
|
37729
37773
|
async composeAddAndTrustServerMessage(input) {
|
|
37730
37774
|
const domain = await this.getServersDomain();
|
|
37775
|
+
console.debug(domain);
|
|
37731
37776
|
return {
|
|
37732
37777
|
domain,
|
|
37733
37778
|
types: {
|
|
37734
|
-
|
|
37779
|
+
AddServer: [
|
|
37735
37780
|
{ name: "nonce", type: "uint256" },
|
|
37736
|
-
{ name: "owner", type: "address" },
|
|
37737
37781
|
{ name: "serverAddress", type: "address" },
|
|
37738
|
-
{ name: "publicKey", type: "
|
|
37782
|
+
{ name: "publicKey", type: "string" },
|
|
37739
37783
|
{ name: "serverUrl", type: "string" }
|
|
37740
37784
|
]
|
|
37741
37785
|
},
|
|
37742
|
-
primaryType: "
|
|
37786
|
+
primaryType: "AddServer",
|
|
37743
37787
|
message: input
|
|
37744
37788
|
};
|
|
37745
37789
|
}
|
|
@@ -37820,7 +37864,6 @@ var PermissionsController = class {
|
|
|
37820
37864
|
contractAddress: DataPortabilityServersAddress,
|
|
37821
37865
|
input: {
|
|
37822
37866
|
nonce: addAndTrustServerInput.nonce.toString(),
|
|
37823
|
-
owner: addAndTrustServerInput.owner,
|
|
37824
37867
|
serverAddress: addAndTrustServerInput.serverAddress,
|
|
37825
37868
|
publicKey: addAndTrustServerInput.publicKey,
|
|
37826
37869
|
serverUrl: addAndTrustServerInput.serverUrl
|
|
@@ -37834,7 +37877,6 @@ var PermissionsController = class {
|
|
|
37834
37877
|
args: [
|
|
37835
37878
|
{
|
|
37836
37879
|
nonce: addAndTrustServerInput.nonce,
|
|
37837
|
-
owner: addAndTrustServerInput.owner,
|
|
37838
37880
|
serverAddress: addAndTrustServerInput.serverAddress,
|
|
37839
37881
|
publicKey: addAndTrustServerInput.publicKey,
|
|
37840
37882
|
serverUrl: addAndTrustServerInput.serverUrl
|
|
@@ -37987,7 +38029,7 @@ var PermissionsController = class {
|
|
|
37987
38029
|
* ```
|
|
37988
38030
|
*/
|
|
37989
38031
|
async submitRegisterGranteeWithSignature(params) {
|
|
37990
|
-
const nonce = await this.
|
|
38032
|
+
const nonce = await this.getServersUserNonce();
|
|
37991
38033
|
const registerGranteeInput = {
|
|
37992
38034
|
nonce,
|
|
37993
38035
|
owner: params.owner,
|
|
@@ -39144,7 +39186,7 @@ var PermissionsController = class {
|
|
|
39144
39186
|
*/
|
|
39145
39187
|
async submitAddPermission(params) {
|
|
39146
39188
|
try {
|
|
39147
|
-
const nonce = await this.
|
|
39189
|
+
const nonce = await this.getPermissionsUserNonce();
|
|
39148
39190
|
const addPermissionInput = {
|
|
39149
39191
|
nonce,
|
|
39150
39192
|
granteeId: params.granteeId,
|
|
@@ -39198,7 +39240,7 @@ var PermissionsController = class {
|
|
|
39198
39240
|
*/
|
|
39199
39241
|
async submitAddServerFilesAndPermissions(params) {
|
|
39200
39242
|
try {
|
|
39201
|
-
const nonce = await this.
|
|
39243
|
+
const nonce = await this.getPermissionsUserNonce();
|
|
39202
39244
|
const serverFilesAndPermissionInput = {
|
|
39203
39245
|
nonce,
|
|
39204
39246
|
granteeId: params.granteeId,
|