@opendatalabs/vana-sdk 0.1.0-alpha.1bbb6d4 → 0.1.0-alpha.273dc39
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 +42 -0
- package/dist/chains.browser.cjs +2 -2
- package/dist/chains.browser.cjs.map +1 -1
- package/dist/chains.browser.js +2 -2
- package/dist/chains.browser.js.map +1 -1
- package/dist/chains.cjs +2 -2
- package/dist/chains.cjs.map +1 -1
- package/dist/chains.js +2 -2
- package/dist/chains.js.map +1 -1
- package/dist/chains.node.cjs +2 -2
- package/dist/chains.node.cjs.map +1 -1
- package/dist/chains.node.js +2 -2
- package/dist/chains.node.js.map +1 -1
- package/dist/index.browser.d.ts +861 -160
- package/dist/index.browser.js +1802 -693
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +1824 -714
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.cts +889 -165
- package/dist/index.node.d.ts +889 -165
- package/dist/index.node.js +1809 -700
- package/dist/index.node.js.map +1 -1
- package/package.json +11 -10
package/dist/index.browser.js
CHANGED
|
@@ -892,12 +892,486 @@ var PermissionError = class extends VanaError {
|
|
|
892
892
|
}
|
|
893
893
|
};
|
|
894
894
|
|
|
895
|
+
// src/utils/multicall.ts
|
|
896
|
+
import { encodeFunctionData, size } from "viem";
|
|
897
|
+
|
|
898
|
+
// src/config/addresses.ts
|
|
899
|
+
var CONTRACTS = {
|
|
900
|
+
// Data Portability Contracts (New Architecture)
|
|
901
|
+
DataPortabilityPermissions: {
|
|
902
|
+
addresses: {
|
|
903
|
+
14800: "0xD54523048AdD05b4d734aFaE7C68324Ebb7373eF",
|
|
904
|
+
1480: "0xD54523048AdD05b4d734aFaE7C68324Ebb7373eF"
|
|
905
|
+
}
|
|
906
|
+
},
|
|
907
|
+
DataPortabilityServers: {
|
|
908
|
+
addresses: {
|
|
909
|
+
14800: "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c",
|
|
910
|
+
1480: "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c"
|
|
911
|
+
}
|
|
912
|
+
},
|
|
913
|
+
DataPortabilityGrantees: {
|
|
914
|
+
addresses: {
|
|
915
|
+
14800: "0x8325C0A0948483EdA023A1A2Fd895e62C5131234",
|
|
916
|
+
1480: "0x8325C0A0948483EdA023A1A2Fd895e62C5131234"
|
|
917
|
+
}
|
|
918
|
+
},
|
|
919
|
+
DataRegistry: {
|
|
920
|
+
addresses: {
|
|
921
|
+
14800: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C",
|
|
922
|
+
1480: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C"
|
|
923
|
+
}
|
|
924
|
+
},
|
|
925
|
+
TeePoolPhala: {
|
|
926
|
+
addresses: {
|
|
927
|
+
14800: "0xE8EC6BD73b23Ad40E6B9a6f4bD343FAc411bD99A",
|
|
928
|
+
1480: "0xE8EC6BD73b23Ad40E6B9a6f4bD343FAc411bD99A"
|
|
929
|
+
}
|
|
930
|
+
},
|
|
931
|
+
ComputeEngine: {
|
|
932
|
+
addresses: {
|
|
933
|
+
14800: "0xb2BFe33FA420c45F1Cf1287542ad81ae935447bd",
|
|
934
|
+
1480: "0xb2BFe33FA420c45F1Cf1287542ad81ae935447bd"
|
|
935
|
+
}
|
|
936
|
+
},
|
|
937
|
+
// Data Access Infrastructure
|
|
938
|
+
DataRefinerRegistry: {
|
|
939
|
+
addresses: {
|
|
940
|
+
14800: "0x93c3EF89369fDcf08Be159D9DeF0F18AB6Be008c",
|
|
941
|
+
1480: "0x93c3EF89369fDcf08Be159D9DeF0F18AB6Be008c"
|
|
942
|
+
}
|
|
943
|
+
},
|
|
944
|
+
QueryEngine: {
|
|
945
|
+
addresses: {
|
|
946
|
+
14800: "0xd25Eb66EA2452cf3238A2eC6C1FD1B7F5B320490",
|
|
947
|
+
1480: "0xd25Eb66EA2452cf3238A2eC6C1FD1B7F5B320490"
|
|
948
|
+
}
|
|
949
|
+
},
|
|
950
|
+
VanaTreasury: {
|
|
951
|
+
addresses: {
|
|
952
|
+
14800: "0x94a1E56e555ac48d092f490fB10CDFaB434915eD",
|
|
953
|
+
1480: "0x94a1E56e555ac48d092f490fB10CDFaB434915eD"
|
|
954
|
+
}
|
|
955
|
+
},
|
|
956
|
+
ComputeInstructionRegistry: {
|
|
957
|
+
addresses: {
|
|
958
|
+
14800: "0x5786B12b4c6Ba2bFAF0e77Ed30Bf6d32805563A5",
|
|
959
|
+
1480: "0x5786B12b4c6Ba2bFAF0e77Ed30Bf6d32805563A5"
|
|
960
|
+
}
|
|
961
|
+
},
|
|
962
|
+
// TEE Pool Variants
|
|
963
|
+
TeePoolEphemeralStandard: {
|
|
964
|
+
addresses: {
|
|
965
|
+
14800: "0xe124bae846D5ec157f75Bd9e68ca87C4d2AB835A",
|
|
966
|
+
1480: "0xe124bae846D5ec157f75Bd9e68ca87C4d2AB835A"
|
|
967
|
+
}
|
|
968
|
+
},
|
|
969
|
+
TeePoolPersistentStandard: {
|
|
970
|
+
addresses: {
|
|
971
|
+
14800: "0xe8bB8d0629651Cf33e0845d743976Dc1f0971d76",
|
|
972
|
+
1480: "0xe8bB8d0629651Cf33e0845d743976Dc1f0971d76"
|
|
973
|
+
}
|
|
974
|
+
},
|
|
975
|
+
TeePoolPersistentGpu: {
|
|
976
|
+
addresses: {
|
|
977
|
+
14800: "0x1c346Cd74f8551f8fa13f3F4b6b8dAE22338E6a9",
|
|
978
|
+
1480: "0x1c346Cd74f8551f8fa13f3F4b6b8dAE22338E6a9"
|
|
979
|
+
}
|
|
980
|
+
},
|
|
981
|
+
TeePoolDedicatedStandard: {
|
|
982
|
+
addresses: {
|
|
983
|
+
14800: "0xf024b7ac5E8417416f53B41ecfa58C8e9396687d",
|
|
984
|
+
1480: "0xf024b7ac5E8417416f53B41ecfa58C8e9396687d"
|
|
985
|
+
}
|
|
986
|
+
},
|
|
987
|
+
TeePoolDedicatedGpu: {
|
|
988
|
+
addresses: {
|
|
989
|
+
14800: "0xB1686FA9620bBf851714d1cB47b8a4Bf4664644E",
|
|
990
|
+
1480: "0xB1686FA9620bBf851714d1cB47b8a4Bf4664644E"
|
|
991
|
+
}
|
|
992
|
+
},
|
|
993
|
+
// DLP Reward System
|
|
994
|
+
VanaEpoch: {
|
|
995
|
+
addresses: {
|
|
996
|
+
14800: "0x2063cFF0609D59bCCc196E20Eb58A8696a6b15A0",
|
|
997
|
+
1480: "0x2063cFF0609D59bCCc196E20Eb58A8696a6b15A0"
|
|
998
|
+
}
|
|
999
|
+
},
|
|
1000
|
+
DLPRegistry: {
|
|
1001
|
+
addresses: {
|
|
1002
|
+
14800: "0x4D59880a924526d1dD33260552Ff4328b1E18a43",
|
|
1003
|
+
1480: "0x4D59880a924526d1dD33260552Ff4328b1E18a43"
|
|
1004
|
+
}
|
|
1005
|
+
},
|
|
1006
|
+
DLPRegistryTreasury: {
|
|
1007
|
+
addresses: {
|
|
1008
|
+
14800: "0xb12ce1d27bEeFe39b6F0110b1AB77C21Aa0c9F9a",
|
|
1009
|
+
1480: "0xb12ce1d27bEeFe39b6F0110b1AB77C21Aa0c9F9a"
|
|
1010
|
+
}
|
|
1011
|
+
},
|
|
1012
|
+
DLPPerformance: {
|
|
1013
|
+
addresses: {
|
|
1014
|
+
14800: "0x847715C7DB37cF286611182Be0bD333cbfa29cc1",
|
|
1015
|
+
1480: "0x847715C7DB37cF286611182Be0bD333cbfa29cc1"
|
|
1016
|
+
}
|
|
1017
|
+
},
|
|
1018
|
+
DLPRewardDeployer: {
|
|
1019
|
+
addresses: {
|
|
1020
|
+
14800: "0xEFD0F9Ba9De70586b7c4189971cF754adC923B04",
|
|
1021
|
+
1480: "0xEFD0F9Ba9De70586b7c4189971cF754adC923B04"
|
|
1022
|
+
}
|
|
1023
|
+
},
|
|
1024
|
+
DLPRewardDeployerTreasury: {
|
|
1025
|
+
addresses: {
|
|
1026
|
+
14800: "0xb547ca8Fe4990fe330FeAeb1C2EBb42F925Af5b8",
|
|
1027
|
+
1480: "0xb547ca8Fe4990fe330FeAeb1C2EBb42F925Af5b8"
|
|
1028
|
+
}
|
|
1029
|
+
},
|
|
1030
|
+
DLPRewardSwap: {
|
|
1031
|
+
addresses: {
|
|
1032
|
+
14800: "0x7c6862C46830F0fc3bF3FF509EA1bD0EE7267fB0",
|
|
1033
|
+
1480: "0x7c6862C46830F0fc3bF3FF509EA1bD0EE7267fB0"
|
|
1034
|
+
}
|
|
1035
|
+
},
|
|
1036
|
+
SwapHelper: {
|
|
1037
|
+
addresses: {
|
|
1038
|
+
14800: "0x55D5e6F73326315bF2E091e97F04f0770e5C54e2",
|
|
1039
|
+
1480: "0x55D5e6F73326315bF2E091e97F04f0770e5C54e2"
|
|
1040
|
+
}
|
|
1041
|
+
},
|
|
1042
|
+
// VanaPool (Staking)
|
|
1043
|
+
VanaPoolStaking: {
|
|
1044
|
+
addresses: {
|
|
1045
|
+
14800: "0x641C18E2F286c86f96CE95C8ec1EB9fC0415Ca0e",
|
|
1046
|
+
1480: "0x641C18E2F286c86f96CE95C8ec1EB9fC0415Ca0e"
|
|
1047
|
+
}
|
|
1048
|
+
},
|
|
1049
|
+
VanaPoolEntity: {
|
|
1050
|
+
addresses: {
|
|
1051
|
+
14800: "0x44f20490A82e1f1F1cC25Dd3BA8647034eDdce30",
|
|
1052
|
+
1480: "0x44f20490A82e1f1F1cC25Dd3BA8647034eDdce30"
|
|
1053
|
+
}
|
|
1054
|
+
},
|
|
1055
|
+
VanaPoolTreasury: {
|
|
1056
|
+
addresses: {
|
|
1057
|
+
14800: "0x143BE72CF2541604A7691933CAccd6D9cC17c003",
|
|
1058
|
+
1480: "0x143BE72CF2541604A7691933CAccd6D9cC17c003"
|
|
1059
|
+
}
|
|
1060
|
+
},
|
|
1061
|
+
// DLP Deployment Contracts
|
|
1062
|
+
DAT: {
|
|
1063
|
+
addresses: {
|
|
1064
|
+
14800: "0xA706b93ccED89f13340673889e29F0a5cd84212d",
|
|
1065
|
+
1480: "0xA706b93ccED89f13340673889e29F0a5cd84212d"
|
|
1066
|
+
}
|
|
1067
|
+
},
|
|
1068
|
+
DATFactory: {
|
|
1069
|
+
addresses: {
|
|
1070
|
+
14800: "0x40f8bccF35a75ecef63BC3B1B3E06ffEB9220644",
|
|
1071
|
+
1480: "0x40f8bccF35a75ecef63BC3B1B3E06ffEB9220644"
|
|
1072
|
+
}
|
|
1073
|
+
},
|
|
1074
|
+
DATPausable: {
|
|
1075
|
+
addresses: {
|
|
1076
|
+
14800: "0xe69FE86f0B95cC2f8416Fe22815c85DC8887e76e",
|
|
1077
|
+
1480: "0xe69FE86f0B95cC2f8416Fe22815c85DC8887e76e"
|
|
1078
|
+
}
|
|
1079
|
+
},
|
|
1080
|
+
DATVotes: {
|
|
1081
|
+
addresses: {
|
|
1082
|
+
14800: "0xaE04c8A77E9B27869eb563720524A9aE0baf1831",
|
|
1083
|
+
1480: "0xaE04c8A77E9B27869eb563720524A9aE0baf1831"
|
|
1084
|
+
}
|
|
1085
|
+
},
|
|
1086
|
+
// Utility Contracts (no ABIs in SDK)
|
|
1087
|
+
Multicall3: {
|
|
1088
|
+
addresses: {
|
|
1089
|
+
14800: "0xD8d2dFca27E8797fd779F8547166A2d3B29d360E",
|
|
1090
|
+
1480: "0xD8d2dFca27E8797fd779F8547166A2d3B29d360E"
|
|
1091
|
+
}
|
|
1092
|
+
},
|
|
1093
|
+
Multisend: {
|
|
1094
|
+
addresses: {
|
|
1095
|
+
14800: "0x8807e8BCDFbaA8c2761760f3FBA37F6f7F2C5b2d",
|
|
1096
|
+
1480: "0x8807e8BCDFbaA8c2761760f3FBA37F6f7F2C5b2d"
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
var LEGACY_CONTRACTS = {
|
|
1101
|
+
// DEPRECATED: Original Intel SGX TeePool (PRO-347)
|
|
1102
|
+
TeePool: {
|
|
1103
|
+
addresses: {
|
|
1104
|
+
14800: "0x3c92fD91639b41f13338CE62f19131e7d19eaa0D",
|
|
1105
|
+
1480: "0x3c92fD91639b41f13338CE62f19131e7d19eaa0D"
|
|
1106
|
+
}
|
|
1107
|
+
},
|
|
1108
|
+
// DEPRECATED: DLPRoot system (replaced by VanaPool + DLPRewards)
|
|
1109
|
+
DLPRootEpoch: {
|
|
1110
|
+
addresses: {
|
|
1111
|
+
14800: "0xc3d176cF6BccFCB9225b53B87a95147218e1537F",
|
|
1112
|
+
1480: "0xc3d176cF6BccFCB9225b53B87a95147218e1537F"
|
|
1113
|
+
}
|
|
1114
|
+
},
|
|
1115
|
+
DLPRootCore: {
|
|
1116
|
+
addresses: {
|
|
1117
|
+
14800: "0x0aBa5e28228c323A67712101d61a54d4ff5720FD",
|
|
1118
|
+
1480: "0x0aBa5e28228c323A67712101d61a54d4ff5720FD"
|
|
1119
|
+
}
|
|
1120
|
+
},
|
|
1121
|
+
DLPRoot: {
|
|
1122
|
+
addresses: {
|
|
1123
|
+
14800: "0xff14346dF2B8Fd0c95BF34f1c92e49417b508AD5",
|
|
1124
|
+
1480: "0xff14346dF2B8Fd0c95BF34f1c92e49417b508AD5"
|
|
1125
|
+
}
|
|
1126
|
+
},
|
|
1127
|
+
DLPRootMetrics: {
|
|
1128
|
+
addresses: {
|
|
1129
|
+
14800: "0xbb532917B6407c060Afd9Cb7d53527eCb91d6662",
|
|
1130
|
+
1480: "0xbb532917B6407c060Afd9Cb7d53527eCb91d6662"
|
|
1131
|
+
}
|
|
1132
|
+
},
|
|
1133
|
+
DLPRootStakesTreasury: {
|
|
1134
|
+
addresses: {
|
|
1135
|
+
14800: "0x52c3260ED5C235fcA43524CF508e29c897318775",
|
|
1136
|
+
1480: "0x52c3260ED5C235fcA43524CF508e29c897318775"
|
|
1137
|
+
}
|
|
1138
|
+
},
|
|
1139
|
+
DLPRootRewardsTreasury: {
|
|
1140
|
+
addresses: {
|
|
1141
|
+
14800: "0xDBFb6B8b9E2eCAEbdE64d665cD553dB81e524479",
|
|
1142
|
+
1480: "0xDBFb6B8b9E2eCAEbdE64d665cD553dB81e524479"
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
};
|
|
1146
|
+
var CONTRACT_ADDRESSES = {
|
|
1147
|
+
14800: Object.fromEntries(
|
|
1148
|
+
Object.entries(CONTRACTS).map(([name, info]) => [name, info.addresses[14800]]).filter(([, addr]) => addr)
|
|
1149
|
+
),
|
|
1150
|
+
1480: Object.fromEntries(
|
|
1151
|
+
Object.entries(CONTRACTS).map(([name, info]) => [name, info.addresses[1480]]).filter(([, addr]) => addr)
|
|
1152
|
+
)
|
|
1153
|
+
};
|
|
1154
|
+
var UTILITY_ADDRESSES = {
|
|
1155
|
+
14800: {
|
|
1156
|
+
Multicall3: CONTRACTS.Multicall3.addresses[14800],
|
|
1157
|
+
Multisend: CONTRACTS.Multisend.addresses[14800]
|
|
1158
|
+
},
|
|
1159
|
+
1480: {
|
|
1160
|
+
Multicall3: CONTRACTS.Multicall3.addresses[1480],
|
|
1161
|
+
Multisend: CONTRACTS.Multisend.addresses[1480]
|
|
1162
|
+
}
|
|
1163
|
+
};
|
|
1164
|
+
var LEGACY_ADDRESSES = {
|
|
1165
|
+
14800: Object.fromEntries(
|
|
1166
|
+
Object.entries(LEGACY_CONTRACTS).map(([name, info]) => [name, info.addresses[14800]]).filter(([, addr]) => addr)
|
|
1167
|
+
),
|
|
1168
|
+
1480: Object.fromEntries(
|
|
1169
|
+
Object.entries(LEGACY_CONTRACTS).map(([name, info]) => [name, info.addresses[1480]]).filter(([, addr]) => addr)
|
|
1170
|
+
)
|
|
1171
|
+
};
|
|
1172
|
+
var getContractAddress = (chainId, contract) => {
|
|
1173
|
+
const contractAddress = CONTRACT_ADDRESSES[chainId]?.[contract];
|
|
1174
|
+
if (!contractAddress) {
|
|
1175
|
+
throw new Error(
|
|
1176
|
+
`Contract address not found for ${contract} on chain ${chainId}`
|
|
1177
|
+
);
|
|
1178
|
+
}
|
|
1179
|
+
return contractAddress;
|
|
1180
|
+
};
|
|
1181
|
+
var getUtilityAddress = (chainId, contract) => {
|
|
1182
|
+
return UTILITY_ADDRESSES[chainId][contract];
|
|
1183
|
+
};
|
|
1184
|
+
|
|
1185
|
+
// src/utils/multicall.ts
|
|
1186
|
+
var DEFAULT_OPTIONS = {
|
|
1187
|
+
maxGasPerBatch: 10000000n,
|
|
1188
|
+
// 10M gas - conservative default
|
|
1189
|
+
maxCalldataBytes: 1e5,
|
|
1190
|
+
// 100KB - works with most RPC providers
|
|
1191
|
+
checkpointFrequency: {
|
|
1192
|
+
calls: 32,
|
|
1193
|
+
bytes: 8192
|
|
1194
|
+
// 8KB
|
|
1195
|
+
},
|
|
1196
|
+
allowFailure: false
|
|
1197
|
+
};
|
|
1198
|
+
async function gasAwareMulticall(client, parameters, options = {}) {
|
|
1199
|
+
const chainId = await client.getChainId();
|
|
1200
|
+
const multicall3Address = options.multicallAddress || getUtilityAddress(chainId, "Multicall3");
|
|
1201
|
+
const opts = {
|
|
1202
|
+
...DEFAULT_OPTIONS,
|
|
1203
|
+
...options,
|
|
1204
|
+
multicallAddress: multicall3Address,
|
|
1205
|
+
checkpointFrequency: {
|
|
1206
|
+
...DEFAULT_OPTIONS.checkpointFrequency,
|
|
1207
|
+
...options.checkpointFrequency
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1210
|
+
if (parameters.allowFailure !== void 0) {
|
|
1211
|
+
opts.allowFailure = parameters.allowFailure;
|
|
1212
|
+
}
|
|
1213
|
+
const { contracts } = parameters;
|
|
1214
|
+
if (!contracts || contracts.length === 0) {
|
|
1215
|
+
return [];
|
|
1216
|
+
}
|
|
1217
|
+
const batches = await createBatches(
|
|
1218
|
+
client,
|
|
1219
|
+
contracts,
|
|
1220
|
+
opts
|
|
1221
|
+
);
|
|
1222
|
+
const batchResults = await Promise.all(
|
|
1223
|
+
batches.map((batch, index) => {
|
|
1224
|
+
if (opts.onProgress && index > 0) {
|
|
1225
|
+
const completed = batches.slice(0, index).reduce((sum, b) => sum + b.length, 0);
|
|
1226
|
+
opts.onProgress(completed, contracts.length);
|
|
1227
|
+
}
|
|
1228
|
+
return client.multicall({
|
|
1229
|
+
...parameters,
|
|
1230
|
+
contracts: batch,
|
|
1231
|
+
multicallAddress: opts.multicallAddress,
|
|
1232
|
+
allowFailure: opts.allowFailure
|
|
1233
|
+
});
|
|
1234
|
+
})
|
|
1235
|
+
);
|
|
1236
|
+
if (opts.onProgress) {
|
|
1237
|
+
opts.onProgress(contracts.length, contracts.length);
|
|
1238
|
+
}
|
|
1239
|
+
return batchResults.flat();
|
|
1240
|
+
}
|
|
1241
|
+
async function createBatches(client, contracts, options) {
|
|
1242
|
+
const batches = [];
|
|
1243
|
+
let currentBatch = [];
|
|
1244
|
+
let currentBytes = 0;
|
|
1245
|
+
let lastCheckpointIndex = 0;
|
|
1246
|
+
let lastCheckpointBytes = 0;
|
|
1247
|
+
let lastEstimatedGas = 0n;
|
|
1248
|
+
for (let i = 0; i < contracts.length; i++) {
|
|
1249
|
+
const contract = contracts[i];
|
|
1250
|
+
const encoded = encodeContractCall(contract);
|
|
1251
|
+
const callBytes = size(encoded);
|
|
1252
|
+
const callsSinceCheckpoint = i - lastCheckpointIndex;
|
|
1253
|
+
const bytesSinceCheckpoint = currentBytes - lastCheckpointBytes;
|
|
1254
|
+
const needsCheckpoint = callsSinceCheckpoint >= options.checkpointFrequency.calls || bytesSinceCheckpoint >= options.checkpointFrequency.bytes;
|
|
1255
|
+
if (needsCheckpoint && currentBatch.length > 0) {
|
|
1256
|
+
try {
|
|
1257
|
+
lastEstimatedGas = await estimateBatchGas(
|
|
1258
|
+
client,
|
|
1259
|
+
currentBatch,
|
|
1260
|
+
options.multicallAddress
|
|
1261
|
+
);
|
|
1262
|
+
lastCheckpointIndex = i;
|
|
1263
|
+
lastCheckpointBytes = currentBytes;
|
|
1264
|
+
} catch (error) {
|
|
1265
|
+
if (currentBatch.length > 1) {
|
|
1266
|
+
const halfBatch = currentBatch.slice(
|
|
1267
|
+
0,
|
|
1268
|
+
Math.floor(currentBatch.length / 2)
|
|
1269
|
+
);
|
|
1270
|
+
batches.push(halfBatch);
|
|
1271
|
+
currentBatch = currentBatch.slice(halfBatch.length);
|
|
1272
|
+
currentBytes = calculateBatchSize(currentBatch);
|
|
1273
|
+
lastCheckpointIndex = i;
|
|
1274
|
+
lastCheckpointBytes = currentBytes;
|
|
1275
|
+
lastEstimatedGas = 0n;
|
|
1276
|
+
} else {
|
|
1277
|
+
if (!options.allowFailure) {
|
|
1278
|
+
throw new Error(`Gas estimation failed for call ${i}: ${error}`);
|
|
1279
|
+
}
|
|
1280
|
+
currentBatch = [];
|
|
1281
|
+
currentBytes = 0;
|
|
1282
|
+
continue;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
const wouldExceedCalldata = currentBytes + callBytes > options.maxCalldataBytes;
|
|
1287
|
+
const wouldExceedGas = lastEstimatedGas > 0n && estimateNextGas(lastEstimatedGas, callsSinceCheckpoint + 1) > options.maxGasPerBatch;
|
|
1288
|
+
if ((wouldExceedCalldata || wouldExceedGas) && currentBatch.length > 0) {
|
|
1289
|
+
batches.push(currentBatch);
|
|
1290
|
+
currentBatch = [];
|
|
1291
|
+
currentBytes = 0;
|
|
1292
|
+
lastCheckpointIndex = i;
|
|
1293
|
+
lastCheckpointBytes = 0;
|
|
1294
|
+
lastEstimatedGas = 0n;
|
|
1295
|
+
}
|
|
1296
|
+
currentBatch.push(contract);
|
|
1297
|
+
currentBytes += callBytes;
|
|
1298
|
+
}
|
|
1299
|
+
if (currentBatch.length > 0) {
|
|
1300
|
+
batches.push(currentBatch);
|
|
1301
|
+
}
|
|
1302
|
+
return batches;
|
|
1303
|
+
}
|
|
1304
|
+
function encodeContractCall(contract) {
|
|
1305
|
+
const { abi, functionName, args } = contract;
|
|
1306
|
+
return encodeFunctionData({
|
|
1307
|
+
abi,
|
|
1308
|
+
functionName,
|
|
1309
|
+
args
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
function calculateBatchSize(batch) {
|
|
1313
|
+
return batch.reduce((total, contract) => {
|
|
1314
|
+
const encoded = encodeContractCall(contract);
|
|
1315
|
+
return total + size(encoded);
|
|
1316
|
+
}, 0);
|
|
1317
|
+
}
|
|
1318
|
+
async function estimateBatchGas(client, batch, multicallAddress) {
|
|
1319
|
+
const calls = batch.map((contract) => ({
|
|
1320
|
+
target: contract.address,
|
|
1321
|
+
allowFailure: false,
|
|
1322
|
+
callData: encodeContractCall(contract)
|
|
1323
|
+
}));
|
|
1324
|
+
const gas = await client.estimateGas({
|
|
1325
|
+
to: multicallAddress,
|
|
1326
|
+
data: encodeFunctionData({
|
|
1327
|
+
abi: multicall3Abi,
|
|
1328
|
+
functionName: "aggregate3",
|
|
1329
|
+
args: [calls]
|
|
1330
|
+
})
|
|
1331
|
+
});
|
|
1332
|
+
return gas;
|
|
1333
|
+
}
|
|
1334
|
+
function estimateNextGas(lastGas, callsSinceCheckpoint) {
|
|
1335
|
+
if (callsSinceCheckpoint === 0) return lastGas;
|
|
1336
|
+
const avgGasPerCall = lastGas / BigInt(Math.max(1, callsSinceCheckpoint - 1));
|
|
1337
|
+
const estimatedGas = lastGas + avgGasPerCall;
|
|
1338
|
+
return estimatedGas * 110n / 100n;
|
|
1339
|
+
}
|
|
1340
|
+
var multicall3Abi = [
|
|
1341
|
+
{
|
|
1342
|
+
name: "aggregate3",
|
|
1343
|
+
type: "function",
|
|
1344
|
+
stateMutability: "payable",
|
|
1345
|
+
inputs: [
|
|
1346
|
+
{
|
|
1347
|
+
name: "calls",
|
|
1348
|
+
type: "tuple[]",
|
|
1349
|
+
components: [
|
|
1350
|
+
{ name: "target", type: "address" },
|
|
1351
|
+
{ name: "allowFailure", type: "bool" },
|
|
1352
|
+
{ name: "callData", type: "bytes" }
|
|
1353
|
+
]
|
|
1354
|
+
}
|
|
1355
|
+
],
|
|
1356
|
+
outputs: [
|
|
1357
|
+
{
|
|
1358
|
+
name: "returnData",
|
|
1359
|
+
type: "tuple[]",
|
|
1360
|
+
components: [
|
|
1361
|
+
{ name: "success", type: "bool" },
|
|
1362
|
+
{ name: "returnData", type: "bytes" }
|
|
1363
|
+
]
|
|
1364
|
+
}
|
|
1365
|
+
]
|
|
1366
|
+
}
|
|
1367
|
+
];
|
|
1368
|
+
|
|
895
1369
|
// src/utils/transactionParsing.ts
|
|
896
1370
|
import { parseEventLogs } from "viem";
|
|
897
1371
|
|
|
898
1372
|
// src/config/eventMappings.ts
|
|
899
1373
|
var EVENT_MAPPINGS = {
|
|
900
|
-
//
|
|
1374
|
+
// DataPortabilityPermissions operations
|
|
901
1375
|
grant: {
|
|
902
1376
|
contract: "DataPortabilityPermissions",
|
|
903
1377
|
event: "PermissionAdded"
|
|
@@ -906,6 +1380,15 @@ var EVENT_MAPPINGS = {
|
|
|
906
1380
|
contract: "DataPortabilityPermissions",
|
|
907
1381
|
event: "PermissionRevoked"
|
|
908
1382
|
},
|
|
1383
|
+
revokePermission: {
|
|
1384
|
+
contract: "DataPortabilityPermissions",
|
|
1385
|
+
event: "PermissionRevoked"
|
|
1386
|
+
},
|
|
1387
|
+
addServerFilesAndPermissions: {
|
|
1388
|
+
contract: "DataPortabilityPermissions",
|
|
1389
|
+
event: "PermissionAdded"
|
|
1390
|
+
},
|
|
1391
|
+
// DataPortabilityServers operations
|
|
909
1392
|
trustServer: {
|
|
910
1393
|
contract: "DataPortabilityServers",
|
|
911
1394
|
event: "ServerTrusted"
|
|
@@ -914,15 +1397,51 @@ var EVENT_MAPPINGS = {
|
|
|
914
1397
|
contract: "DataPortabilityServers",
|
|
915
1398
|
event: "ServerUntrusted"
|
|
916
1399
|
},
|
|
917
|
-
|
|
1400
|
+
registerServer: {
|
|
1401
|
+
contract: "DataPortabilityServers",
|
|
1402
|
+
event: "ServerRegistered"
|
|
1403
|
+
},
|
|
1404
|
+
updateServer: {
|
|
1405
|
+
contract: "DataPortabilityServers",
|
|
1406
|
+
event: "ServerUpdated"
|
|
1407
|
+
},
|
|
1408
|
+
addAndTrustServer: {
|
|
1409
|
+
contract: "DataPortabilityServers",
|
|
1410
|
+
event: "ServerTrusted"
|
|
1411
|
+
},
|
|
1412
|
+
// DataRegistry operations
|
|
918
1413
|
addFile: {
|
|
919
1414
|
contract: "DataRegistry",
|
|
920
1415
|
event: "FileAdded"
|
|
921
1416
|
},
|
|
1417
|
+
addFileWithPermissionsAndSchema: {
|
|
1418
|
+
contract: "DataRegistry",
|
|
1419
|
+
event: "FileAdded"
|
|
1420
|
+
},
|
|
1421
|
+
addFileWithSchema: {
|
|
1422
|
+
contract: "DataRegistry",
|
|
1423
|
+
event: "FileAdded"
|
|
1424
|
+
},
|
|
1425
|
+
addFileWithPermissions: {
|
|
1426
|
+
contract: "DataRegistry",
|
|
1427
|
+
event: "FileAdded"
|
|
1428
|
+
},
|
|
922
1429
|
addRefinement: {
|
|
923
1430
|
contract: "DataRegistry",
|
|
924
1431
|
event: "RefinementAdded"
|
|
925
1432
|
},
|
|
1433
|
+
addRefiner: {
|
|
1434
|
+
contract: "DataRefinerRegistry",
|
|
1435
|
+
event: "RefinerAdded"
|
|
1436
|
+
},
|
|
1437
|
+
updateSchemaId: {
|
|
1438
|
+
contract: "DataRefinerRegistry",
|
|
1439
|
+
event: "SchemaAdded"
|
|
1440
|
+
},
|
|
1441
|
+
addSchema: {
|
|
1442
|
+
contract: "DataRefinerRegistry",
|
|
1443
|
+
event: "SchemaAdded"
|
|
1444
|
+
},
|
|
926
1445
|
updateRefinement: {
|
|
927
1446
|
contract: "DataRegistry",
|
|
928
1447
|
event: "RefinementUpdated"
|
|
@@ -930,10 +1449,15 @@ var EVENT_MAPPINGS = {
|
|
|
930
1449
|
addFilePermission: {
|
|
931
1450
|
contract: "DataRegistry",
|
|
932
1451
|
event: "PermissionGranted"
|
|
1452
|
+
},
|
|
1453
|
+
// DataPortabilityGrantees operations
|
|
1454
|
+
registerGrantee: {
|
|
1455
|
+
contract: "DataPortabilityGrantees",
|
|
1456
|
+
event: "GranteeRegistered"
|
|
933
1457
|
}
|
|
934
1458
|
};
|
|
935
1459
|
|
|
936
|
-
// src/abi/ComputeEngineImplementation.ts
|
|
1460
|
+
// src/generated/abi/ComputeEngineImplementation.ts
|
|
937
1461
|
var ComputeEngineABI = [
|
|
938
1462
|
{
|
|
939
1463
|
inputs: [],
|
|
@@ -2218,7 +2742,7 @@ var ComputeEngineABI = [
|
|
|
2218
2742
|
}
|
|
2219
2743
|
];
|
|
2220
2744
|
|
|
2221
|
-
// src/abi/DataRegistryImplementation.ts
|
|
2745
|
+
// src/generated/abi/DataRegistryImplementation.ts
|
|
2222
2746
|
var DataRegistryABI = [
|
|
2223
2747
|
{
|
|
2224
2748
|
inputs: [],
|
|
@@ -3408,7 +3932,7 @@ var DataRegistryABI = [
|
|
|
3408
3932
|
}
|
|
3409
3933
|
];
|
|
3410
3934
|
|
|
3411
|
-
// src/abi/TeePoolImplementation.ts
|
|
3935
|
+
// src/generated/abi/TeePoolImplementation.ts
|
|
3412
3936
|
var TeePoolABI = [
|
|
3413
3937
|
{
|
|
3414
3938
|
inputs: [],
|
|
@@ -4693,7 +5217,7 @@ var TeePoolABI = [
|
|
|
4693
5217
|
}
|
|
4694
5218
|
];
|
|
4695
5219
|
|
|
4696
|
-
// src/abi/TeePoolPhalaImplementation.ts
|
|
5220
|
+
// src/generated/abi/TeePoolPhalaImplementation.ts
|
|
4697
5221
|
var TeePoolPhalaABI = [
|
|
4698
5222
|
{
|
|
4699
5223
|
inputs: [],
|
|
@@ -5978,7 +6502,7 @@ var TeePoolPhalaABI = [
|
|
|
5978
6502
|
}
|
|
5979
6503
|
];
|
|
5980
6504
|
|
|
5981
|
-
// src/abi/DataPortabilityPermissionsImplementation.ts
|
|
6505
|
+
// src/generated/abi/DataPortabilityPermissionsImplementation.ts
|
|
5982
6506
|
var DataPortabilityPermissionsABI = [
|
|
5983
6507
|
{
|
|
5984
6508
|
inputs: [],
|
|
@@ -7246,7 +7770,7 @@ var DataPortabilityPermissionsABI = [
|
|
|
7246
7770
|
}
|
|
7247
7771
|
];
|
|
7248
7772
|
|
|
7249
|
-
// src/abi/DataPortabilityServersImplementation.ts
|
|
7773
|
+
// src/generated/abi/DataPortabilityServersImplementation.ts
|
|
7250
7774
|
var DataPortabilityServersABI = [
|
|
7251
7775
|
{
|
|
7252
7776
|
inputs: [],
|
|
@@ -8638,7 +9162,7 @@ var DataPortabilityServersABI = [
|
|
|
8638
9162
|
}
|
|
8639
9163
|
];
|
|
8640
9164
|
|
|
8641
|
-
// src/abi/DataPortabilityGranteesImplementation.ts
|
|
9165
|
+
// src/generated/abi/DataPortabilityGranteesImplementation.ts
|
|
8642
9166
|
var DataPortabilityGranteesABI = [
|
|
8643
9167
|
{
|
|
8644
9168
|
inputs: [],
|
|
@@ -9498,7 +10022,7 @@ var DataPortabilityGranteesABI = [
|
|
|
9498
10022
|
}
|
|
9499
10023
|
];
|
|
9500
10024
|
|
|
9501
|
-
// src/abi/DataRefinerRegistryImplementation.ts
|
|
10025
|
+
// src/generated/abi/DataRefinerRegistryImplementation.ts
|
|
9502
10026
|
var DataRefinerRegistryABI = [
|
|
9503
10027
|
{
|
|
9504
10028
|
inputs: [],
|
|
@@ -10454,7 +10978,7 @@ var DataRefinerRegistryABI = [
|
|
|
10454
10978
|
}
|
|
10455
10979
|
];
|
|
10456
10980
|
|
|
10457
|
-
// src/abi/QueryEngineImplementation.ts
|
|
10981
|
+
// src/generated/abi/QueryEngineImplementation.ts
|
|
10458
10982
|
var QueryEngineABI = [
|
|
10459
10983
|
{
|
|
10460
10984
|
inputs: [],
|
|
@@ -11745,7 +12269,7 @@ var QueryEngineABI = [
|
|
|
11745
12269
|
}
|
|
11746
12270
|
];
|
|
11747
12271
|
|
|
11748
|
-
// src/abi/ComputeInstructionRegistryImplementation.ts
|
|
12272
|
+
// src/generated/abi/ComputeInstructionRegistryImplementation.ts
|
|
11749
12273
|
var ComputeInstructionRegistryABI = [
|
|
11750
12274
|
{
|
|
11751
12275
|
inputs: [],
|
|
@@ -12451,7 +12975,7 @@ var ComputeInstructionRegistryABI = [
|
|
|
12451
12975
|
}
|
|
12452
12976
|
];
|
|
12453
12977
|
|
|
12454
|
-
// src/abi/TeePoolEphemeralStandardImplementation.ts
|
|
12978
|
+
// src/generated/abi/TeePoolEphemeralStandardImplementation.ts
|
|
12455
12979
|
var TeePoolEphemeralStandardABI = [
|
|
12456
12980
|
{
|
|
12457
12981
|
inputs: [],
|
|
@@ -13359,7 +13883,7 @@ var TeePoolEphemeralStandardABI = [
|
|
|
13359
13883
|
}
|
|
13360
13884
|
];
|
|
13361
13885
|
|
|
13362
|
-
// src/abi/TeePoolPersistentStandardImplementation.ts
|
|
13886
|
+
// src/generated/abi/TeePoolPersistentStandardImplementation.ts
|
|
13363
13887
|
var TeePoolPersistentStandardABI = [
|
|
13364
13888
|
{
|
|
13365
13889
|
inputs: [],
|
|
@@ -14267,7 +14791,7 @@ var TeePoolPersistentStandardABI = [
|
|
|
14267
14791
|
}
|
|
14268
14792
|
];
|
|
14269
14793
|
|
|
14270
|
-
// src/abi/TeePoolPersistentGpuImplementation.ts
|
|
14794
|
+
// src/generated/abi/TeePoolPersistentGpuImplementation.ts
|
|
14271
14795
|
var TeePoolPersistentGpuABI = [
|
|
14272
14796
|
{
|
|
14273
14797
|
inputs: [],
|
|
@@ -15175,7 +15699,7 @@ var TeePoolPersistentGpuABI = [
|
|
|
15175
15699
|
}
|
|
15176
15700
|
];
|
|
15177
15701
|
|
|
15178
|
-
// src/abi/TeePoolDedicatedStandardImplementation.ts
|
|
15702
|
+
// src/generated/abi/TeePoolDedicatedStandardImplementation.ts
|
|
15179
15703
|
var TeePoolDedicatedStandardABI = [
|
|
15180
15704
|
{
|
|
15181
15705
|
inputs: [],
|
|
@@ -16083,7 +16607,7 @@ var TeePoolDedicatedStandardABI = [
|
|
|
16083
16607
|
}
|
|
16084
16608
|
];
|
|
16085
16609
|
|
|
16086
|
-
// src/abi/TeePoolDedicatedGpuImplementation.ts
|
|
16610
|
+
// src/generated/abi/TeePoolDedicatedGpuImplementation.ts
|
|
16087
16611
|
var TeePoolDedicatedGpuABI = [
|
|
16088
16612
|
{
|
|
16089
16613
|
inputs: [],
|
|
@@ -16991,7 +17515,7 @@ var TeePoolDedicatedGpuABI = [
|
|
|
16991
17515
|
}
|
|
16992
17516
|
];
|
|
16993
17517
|
|
|
16994
|
-
// src/abi/VanaEpochImplementation.ts
|
|
17518
|
+
// src/generated/abi/VanaEpochImplementation.ts
|
|
16995
17519
|
var VanaEpochABI = [
|
|
16996
17520
|
{
|
|
16997
17521
|
inputs: [],
|
|
@@ -18151,7 +18675,7 @@ var VanaEpochABI = [
|
|
|
18151
18675
|
}
|
|
18152
18676
|
];
|
|
18153
18677
|
|
|
18154
|
-
// src/abi/DLPRegistryImplementation.ts
|
|
18678
|
+
// src/generated/abi/DLPRegistryImplementation.ts
|
|
18155
18679
|
var DLPRegistryABI = [
|
|
18156
18680
|
{
|
|
18157
18681
|
inputs: [],
|
|
@@ -19592,7 +20116,7 @@ var DLPRegistryABI = [
|
|
|
19592
20116
|
}
|
|
19593
20117
|
];
|
|
19594
20118
|
|
|
19595
|
-
// src/abi/DLPTreasuryImplementation.ts
|
|
20119
|
+
// src/generated/abi/DLPTreasuryImplementation.ts
|
|
19596
20120
|
var DLPRegistryTreasuryABI = [
|
|
19597
20121
|
{
|
|
19598
20122
|
inputs: [],
|
|
@@ -20176,7 +20700,7 @@ var DLPRegistryTreasuryABI = [
|
|
|
20176
20700
|
}
|
|
20177
20701
|
];
|
|
20178
20702
|
|
|
20179
|
-
// src/abi/DLPRewardDeployerTreasuryImplementation.ts
|
|
20703
|
+
// src/generated/abi/DLPRewardDeployerTreasuryImplementation.ts
|
|
20180
20704
|
var DLPRewardDeployerTreasuryABI = [
|
|
20181
20705
|
{
|
|
20182
20706
|
inputs: [],
|
|
@@ -20760,7 +21284,7 @@ var DLPRewardDeployerTreasuryABI = [
|
|
|
20760
21284
|
}
|
|
20761
21285
|
];
|
|
20762
21286
|
|
|
20763
|
-
// src/abi/DLPPerformanceImplementation.ts
|
|
21287
|
+
// src/generated/abi/DLPPerformanceImplementation.ts
|
|
20764
21288
|
var DLPPerformanceABI = [
|
|
20765
21289
|
{
|
|
20766
21290
|
inputs: [],
|
|
@@ -21892,7 +22416,7 @@ var DLPPerformanceABI = [
|
|
|
21892
22416
|
}
|
|
21893
22417
|
];
|
|
21894
22418
|
|
|
21895
|
-
// src/abi/DLPRewardDeployerImplementation.ts
|
|
22419
|
+
// src/generated/abi/DLPRewardDeployerImplementation.ts
|
|
21896
22420
|
var DLPRewardDeployerABI = [
|
|
21897
22421
|
{
|
|
21898
22422
|
inputs: [],
|
|
@@ -22812,7 +23336,7 @@ var DLPRewardDeployerABI = [
|
|
|
22812
23336
|
}
|
|
22813
23337
|
];
|
|
22814
23338
|
|
|
22815
|
-
// src/abi/DLPRewardSwapImplementation.ts
|
|
23339
|
+
// src/generated/abi/DLPRewardSwapImplementation.ts
|
|
22816
23340
|
var DLPRewardSwapABI = [
|
|
22817
23341
|
{
|
|
22818
23342
|
inputs: [],
|
|
@@ -23723,7 +24247,7 @@ var DLPRewardSwapABI = [
|
|
|
23723
24247
|
}
|
|
23724
24248
|
];
|
|
23725
24249
|
|
|
23726
|
-
// src/abi/SwapHelperImplementation.ts
|
|
24250
|
+
// src/generated/abi/SwapHelperImplementation.ts
|
|
23727
24251
|
var SwapHelperABI = [
|
|
23728
24252
|
{
|
|
23729
24253
|
inputs: [],
|
|
@@ -24714,7 +25238,7 @@ var SwapHelperABI = [
|
|
|
24714
25238
|
}
|
|
24715
25239
|
];
|
|
24716
25240
|
|
|
24717
|
-
// src/abi/DLPRootImplementation.ts
|
|
25241
|
+
// src/generated/abi/DLPRootImplementation.ts
|
|
24718
25242
|
var DLPRootImplementation2Abi = [
|
|
24719
25243
|
{
|
|
24720
25244
|
inputs: [],
|
|
@@ -26332,7 +26856,7 @@ var DLPRootImplementation2Abi = [
|
|
|
26332
26856
|
}
|
|
26333
26857
|
];
|
|
26334
26858
|
|
|
26335
|
-
// src/abi/DataLiquidityPoolImplementation.ts
|
|
26859
|
+
// src/generated/abi/DataLiquidityPoolImplementation.ts
|
|
26336
26860
|
var DataLiquidityPoolImplementationAbi = [
|
|
26337
26861
|
{
|
|
26338
26862
|
inputs: [],
|
|
@@ -27291,7 +27815,7 @@ var DataLiquidityPoolImplementationAbi = [
|
|
|
27291
27815
|
}
|
|
27292
27816
|
];
|
|
27293
27817
|
|
|
27294
|
-
// src/abi/DLPRegistryTreasuryImplementation.ts
|
|
27818
|
+
// src/generated/abi/DLPRegistryTreasuryImplementation.ts
|
|
27295
27819
|
var DLPRegistryTreasuryABI2 = [
|
|
27296
27820
|
{
|
|
27297
27821
|
inputs: [],
|
|
@@ -27875,7 +28399,7 @@ var DLPRegistryTreasuryABI2 = [
|
|
|
27875
28399
|
}
|
|
27876
28400
|
];
|
|
27877
28401
|
|
|
27878
|
-
// src/abi/VanaPoolStakingImplementation.ts
|
|
28402
|
+
// src/generated/abi/VanaPoolStakingImplementation.ts
|
|
27879
28403
|
var VanaPoolStakingABI = [
|
|
27880
28404
|
{
|
|
27881
28405
|
inputs: [],
|
|
@@ -28768,7 +29292,7 @@ var VanaPoolStakingABI = [
|
|
|
28768
29292
|
}
|
|
28769
29293
|
];
|
|
28770
29294
|
|
|
28771
|
-
// src/abi/VanaPoolEntityImplementation.ts
|
|
29295
|
+
// src/generated/abi/VanaPoolEntityImplementation.ts
|
|
28772
29296
|
var VanaPoolEntityABI = [
|
|
28773
29297
|
{
|
|
28774
29298
|
inputs: [],
|
|
@@ -29974,7 +30498,7 @@ var VanaPoolEntityABI = [
|
|
|
29974
30498
|
}
|
|
29975
30499
|
];
|
|
29976
30500
|
|
|
29977
|
-
// src/abi/VanaPoolTreasuryImplementation.ts
|
|
30501
|
+
// src/generated/abi/VanaPoolTreasuryImplementation.ts
|
|
29978
30502
|
var VanaPoolTreasuryABI = [
|
|
29979
30503
|
{
|
|
29980
30504
|
inputs: [],
|
|
@@ -30484,7 +31008,7 @@ var VanaPoolTreasuryABI = [
|
|
|
30484
31008
|
}
|
|
30485
31009
|
];
|
|
30486
31010
|
|
|
30487
|
-
// src/abi/DATImplementation.ts
|
|
31011
|
+
// src/generated/abi/DATImplementation.ts
|
|
30488
31012
|
var DATABI = [
|
|
30489
31013
|
{
|
|
30490
31014
|
inputs: [],
|
|
@@ -31390,7 +31914,7 @@ var DATABI = [
|
|
|
31390
31914
|
}
|
|
31391
31915
|
];
|
|
31392
31916
|
|
|
31393
|
-
// src/abi/DATFactoryImplementation.ts
|
|
31917
|
+
// src/generated/abi/DATFactoryImplementation.ts
|
|
31394
31918
|
var DATFactoryABI = [
|
|
31395
31919
|
{
|
|
31396
31920
|
inputs: [],
|
|
@@ -32244,7 +32768,7 @@ var DATFactoryABI = [
|
|
|
32244
32768
|
}
|
|
32245
32769
|
];
|
|
32246
32770
|
|
|
32247
|
-
// src/abi/DATPausableImplementation.ts
|
|
32771
|
+
// src/generated/abi/DATPausableImplementation.ts
|
|
32248
32772
|
var DATPausableABI = [
|
|
32249
32773
|
{
|
|
32250
32774
|
inputs: [],
|
|
@@ -33739,7 +34263,7 @@ var DATPausableABI = [
|
|
|
33739
34263
|
}
|
|
33740
34264
|
];
|
|
33741
34265
|
|
|
33742
|
-
// src/abi/DATVotesImplementation.ts
|
|
34266
|
+
// src/generated/abi/DATVotesImplementation.ts
|
|
33743
34267
|
var DATVotesABI = [
|
|
33744
34268
|
{
|
|
33745
34269
|
inputs: [],
|
|
@@ -35171,7 +35695,7 @@ var DATVotesABI = [
|
|
|
35171
35695
|
}
|
|
35172
35696
|
];
|
|
35173
35697
|
|
|
35174
|
-
// src/abi/index.ts
|
|
35698
|
+
// src/generated/abi/index.ts
|
|
35175
35699
|
var contractAbis = {
|
|
35176
35700
|
DataPortabilityPermissions: DataPortabilityPermissionsABI,
|
|
35177
35701
|
DataPortabilityServers: DataPortabilityServersABI,
|
|
@@ -35277,288 +35801,99 @@ async function parseTransactionResult(context, hash, operation) {
|
|
|
35277
35801
|
}
|
|
35278
35802
|
}
|
|
35279
35803
|
|
|
35280
|
-
// src/
|
|
35281
|
-
var
|
|
35282
|
-
|
|
35283
|
-
|
|
35284
|
-
|
|
35285
|
-
|
|
35286
|
-
|
|
35287
|
-
|
|
35288
|
-
|
|
35289
|
-
|
|
35290
|
-
addresses: {
|
|
35291
|
-
14800: "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c",
|
|
35292
|
-
1480: "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c"
|
|
35293
|
-
}
|
|
35294
|
-
},
|
|
35295
|
-
DataPortabilityGrantees: {
|
|
35296
|
-
addresses: {
|
|
35297
|
-
14800: "0x8325C0A0948483EdA023A1A2Fd895e62C5131234",
|
|
35298
|
-
1480: "0x8325C0A0948483EdA023A1A2Fd895e62C5131234"
|
|
35299
|
-
}
|
|
35300
|
-
},
|
|
35301
|
-
DataRegistry: {
|
|
35302
|
-
addresses: {
|
|
35303
|
-
14800: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C",
|
|
35304
|
-
1480: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C"
|
|
35305
|
-
}
|
|
35306
|
-
},
|
|
35307
|
-
TeePoolPhala: {
|
|
35308
|
-
addresses: {
|
|
35309
|
-
14800: "0xE8EC6BD73b23Ad40E6B9a6f4bD343FAc411bD99A",
|
|
35310
|
-
1480: "0xE8EC6BD73b23Ad40E6B9a6f4bD343FAc411bD99A"
|
|
35311
|
-
}
|
|
35312
|
-
},
|
|
35313
|
-
ComputeEngine: {
|
|
35314
|
-
addresses: {
|
|
35315
|
-
14800: "0xb2BFe33FA420c45F1Cf1287542ad81ae935447bd",
|
|
35316
|
-
1480: "0xb2BFe33FA420c45F1Cf1287542ad81ae935447bd"
|
|
35317
|
-
}
|
|
35318
|
-
},
|
|
35319
|
-
// Data Access Infrastructure
|
|
35320
|
-
DataRefinerRegistry: {
|
|
35321
|
-
addresses: {
|
|
35322
|
-
14800: "0x93c3EF89369fDcf08Be159D9DeF0F18AB6Be008c",
|
|
35323
|
-
1480: "0x93c3EF89369fDcf08Be159D9DeF0F18AB6Be008c"
|
|
35324
|
-
}
|
|
35325
|
-
},
|
|
35326
|
-
QueryEngine: {
|
|
35327
|
-
addresses: {
|
|
35328
|
-
14800: "0xd25Eb66EA2452cf3238A2eC6C1FD1B7F5B320490",
|
|
35329
|
-
1480: "0xd25Eb66EA2452cf3238A2eC6C1FD1B7F5B320490"
|
|
35330
|
-
}
|
|
35331
|
-
},
|
|
35332
|
-
VanaTreasury: {
|
|
35333
|
-
addresses: {
|
|
35334
|
-
14800: "0x94a1E56e555ac48d092f490fB10CDFaB434915eD",
|
|
35335
|
-
1480: "0x94a1E56e555ac48d092f490fB10CDFaB434915eD"
|
|
35336
|
-
}
|
|
35337
|
-
},
|
|
35338
|
-
ComputeInstructionRegistry: {
|
|
35339
|
-
addresses: {
|
|
35340
|
-
14800: "0x5786B12b4c6Ba2bFAF0e77Ed30Bf6d32805563A5",
|
|
35341
|
-
1480: "0x5786B12b4c6Ba2bFAF0e77Ed30Bf6d32805563A5"
|
|
35342
|
-
}
|
|
35343
|
-
},
|
|
35344
|
-
// TEE Pool Variants
|
|
35345
|
-
TeePoolEphemeralStandard: {
|
|
35346
|
-
addresses: {
|
|
35347
|
-
14800: "0xe124bae846D5ec157f75Bd9e68ca87C4d2AB835A",
|
|
35348
|
-
1480: "0xe124bae846D5ec157f75Bd9e68ca87C4d2AB835A"
|
|
35349
|
-
}
|
|
35350
|
-
},
|
|
35351
|
-
TeePoolPersistentStandard: {
|
|
35352
|
-
addresses: {
|
|
35353
|
-
14800: "0xe8bB8d0629651Cf33e0845d743976Dc1f0971d76",
|
|
35354
|
-
1480: "0xe8bB8d0629651Cf33e0845d743976Dc1f0971d76"
|
|
35355
|
-
}
|
|
35356
|
-
},
|
|
35357
|
-
TeePoolPersistentGpu: {
|
|
35358
|
-
addresses: {
|
|
35359
|
-
14800: "0x1c346Cd74f8551f8fa13f3F4b6b8dAE22338E6a9",
|
|
35360
|
-
1480: "0x1c346Cd74f8551f8fa13f3F4b6b8dAE22338E6a9"
|
|
35361
|
-
}
|
|
35362
|
-
},
|
|
35363
|
-
TeePoolDedicatedStandard: {
|
|
35364
|
-
addresses: {
|
|
35365
|
-
14800: "0xf024b7ac5E8417416f53B41ecfa58C8e9396687d",
|
|
35366
|
-
1480: "0xf024b7ac5E8417416f53B41ecfa58C8e9396687d"
|
|
35367
|
-
}
|
|
35368
|
-
},
|
|
35369
|
-
TeePoolDedicatedGpu: {
|
|
35370
|
-
addresses: {
|
|
35371
|
-
14800: "0xB1686FA9620bBf851714d1cB47b8a4Bf4664644E",
|
|
35372
|
-
1480: "0xB1686FA9620bBf851714d1cB47b8a4Bf4664644E"
|
|
35373
|
-
}
|
|
35374
|
-
},
|
|
35375
|
-
// DLP Reward System
|
|
35376
|
-
VanaEpoch: {
|
|
35377
|
-
addresses: {
|
|
35378
|
-
14800: "0x2063cFF0609D59bCCc196E20Eb58A8696a6b15A0",
|
|
35379
|
-
1480: "0x2063cFF0609D59bCCc196E20Eb58A8696a6b15A0"
|
|
35380
|
-
}
|
|
35381
|
-
},
|
|
35382
|
-
DLPRegistry: {
|
|
35383
|
-
addresses: {
|
|
35384
|
-
14800: "0x4D59880a924526d1dD33260552Ff4328b1E18a43",
|
|
35385
|
-
1480: "0x4D59880a924526d1dD33260552Ff4328b1E18a43"
|
|
35386
|
-
}
|
|
35387
|
-
},
|
|
35388
|
-
DLPRegistryTreasury: {
|
|
35389
|
-
addresses: {
|
|
35390
|
-
14800: "0xb12ce1d27bEeFe39b6F0110b1AB77C21Aa0c9F9a",
|
|
35391
|
-
1480: "0xb12ce1d27bEeFe39b6F0110b1AB77C21Aa0c9F9a"
|
|
35392
|
-
}
|
|
35393
|
-
},
|
|
35394
|
-
DLPPerformance: {
|
|
35395
|
-
addresses: {
|
|
35396
|
-
14800: "0x847715C7DB37cF286611182Be0bD333cbfa29cc1",
|
|
35397
|
-
1480: "0x847715C7DB37cF286611182Be0bD333cbfa29cc1"
|
|
35398
|
-
}
|
|
35399
|
-
},
|
|
35400
|
-
DLPRewardDeployer: {
|
|
35401
|
-
addresses: {
|
|
35402
|
-
14800: "0xEFD0F9Ba9De70586b7c4189971cF754adC923B04",
|
|
35403
|
-
1480: "0xEFD0F9Ba9De70586b7c4189971cF754adC923B04"
|
|
35404
|
-
}
|
|
35405
|
-
},
|
|
35406
|
-
DLPRewardDeployerTreasury: {
|
|
35407
|
-
addresses: {
|
|
35408
|
-
14800: "0xb547ca8Fe4990fe330FeAeb1C2EBb42F925Af5b8",
|
|
35409
|
-
1480: "0xb547ca8Fe4990fe330FeAeb1C2EBb42F925Af5b8"
|
|
35410
|
-
}
|
|
35411
|
-
},
|
|
35412
|
-
DLPRewardSwap: {
|
|
35413
|
-
addresses: {
|
|
35414
|
-
14800: "0x7c6862C46830F0fc3bF3FF509EA1bD0EE7267fB0",
|
|
35415
|
-
1480: "0x7c6862C46830F0fc3bF3FF509EA1bD0EE7267fB0"
|
|
35416
|
-
}
|
|
35417
|
-
},
|
|
35418
|
-
SwapHelper: {
|
|
35419
|
-
addresses: {
|
|
35420
|
-
14800: "0x55D5e6F73326315bF2E091e97F04f0770e5C54e2",
|
|
35421
|
-
1480: "0x55D5e6F73326315bF2E091e97F04f0770e5C54e2"
|
|
35422
|
-
}
|
|
35423
|
-
},
|
|
35424
|
-
// VanaPool (Staking)
|
|
35425
|
-
VanaPoolStaking: {
|
|
35426
|
-
addresses: {
|
|
35427
|
-
14800: "0x641C18E2F286c86f96CE95C8ec1EB9fC0415Ca0e",
|
|
35428
|
-
1480: "0x641C18E2F286c86f96CE95C8ec1EB9fC0415Ca0e"
|
|
35429
|
-
}
|
|
35430
|
-
},
|
|
35431
|
-
VanaPoolEntity: {
|
|
35432
|
-
addresses: {
|
|
35433
|
-
14800: "0x44f20490A82e1f1F1cC25Dd3BA8647034eDdce30",
|
|
35434
|
-
1480: "0x44f20490A82e1f1F1cC25Dd3BA8647034eDdce30"
|
|
35435
|
-
}
|
|
35436
|
-
},
|
|
35437
|
-
VanaPoolTreasury: {
|
|
35438
|
-
addresses: {
|
|
35439
|
-
14800: "0x143BE72CF2541604A7691933CAccd6D9cC17c003",
|
|
35440
|
-
1480: "0x143BE72CF2541604A7691933CAccd6D9cC17c003"
|
|
35441
|
-
}
|
|
35442
|
-
},
|
|
35443
|
-
// DLP Deployment Contracts
|
|
35444
|
-
DAT: {
|
|
35445
|
-
addresses: {
|
|
35446
|
-
14800: "0xA706b93ccED89f13340673889e29F0a5cd84212d",
|
|
35447
|
-
1480: "0xA706b93ccED89f13340673889e29F0a5cd84212d"
|
|
35448
|
-
}
|
|
35449
|
-
},
|
|
35450
|
-
DATFactory: {
|
|
35451
|
-
addresses: {
|
|
35452
|
-
14800: "0x40f8bccF35a75ecef63BC3B1B3E06ffEB9220644",
|
|
35453
|
-
1480: "0x40f8bccF35a75ecef63BC3B1B3E06ffEB9220644"
|
|
35454
|
-
}
|
|
35455
|
-
},
|
|
35456
|
-
DATPausable: {
|
|
35457
|
-
addresses: {
|
|
35458
|
-
14800: "0xe69FE86f0B95cC2f8416Fe22815c85DC8887e76e",
|
|
35459
|
-
1480: "0xe69FE86f0B95cC2f8416Fe22815c85DC8887e76e"
|
|
35460
|
-
}
|
|
35461
|
-
},
|
|
35462
|
-
DATVotes: {
|
|
35463
|
-
addresses: {
|
|
35464
|
-
14800: "0xaE04c8A77E9B27869eb563720524A9aE0baf1831",
|
|
35465
|
-
1480: "0xaE04c8A77E9B27869eb563720524A9aE0baf1831"
|
|
35466
|
-
}
|
|
35467
|
-
},
|
|
35468
|
-
// Utility Contracts (no ABIs in SDK)
|
|
35469
|
-
Multicall3: {
|
|
35470
|
-
addresses: {
|
|
35471
|
-
14800: "0xD8d2dFca27E8797fd779F8547166A2d3B29d360E",
|
|
35472
|
-
1480: "0xD8d2dFca27E8797fd779F8547166A2d3B29d360E"
|
|
35473
|
-
}
|
|
35474
|
-
},
|
|
35475
|
-
Multisend: {
|
|
35476
|
-
addresses: {
|
|
35477
|
-
14800: "0x8807e8BCDFbaA8c2761760f3FBA37F6f7F2C5b2d",
|
|
35478
|
-
1480: "0x8807e8BCDFbaA8c2761760f3FBA37F6f7F2C5b2d"
|
|
35479
|
-
}
|
|
35804
|
+
// src/utils/transactionHandle.ts
|
|
35805
|
+
var TransactionHandle = class {
|
|
35806
|
+
constructor(context, hash, operation) {
|
|
35807
|
+
this.context = context;
|
|
35808
|
+
this.hash = hash;
|
|
35809
|
+
this.operation = operation;
|
|
35810
|
+
__publicField(this, "_receipt");
|
|
35811
|
+
__publicField(this, "_eventData");
|
|
35812
|
+
__publicField(this, "_receiptPromise");
|
|
35813
|
+
__publicField(this, "_eventPromise");
|
|
35480
35814
|
}
|
|
35481
|
-
|
|
35482
|
-
|
|
35483
|
-
|
|
35484
|
-
|
|
35485
|
-
|
|
35486
|
-
|
|
35487
|
-
|
|
35488
|
-
|
|
35489
|
-
|
|
35490
|
-
|
|
35491
|
-
|
|
35492
|
-
|
|
35493
|
-
|
|
35494
|
-
|
|
35495
|
-
|
|
35496
|
-
|
|
35497
|
-
|
|
35498
|
-
|
|
35499
|
-
|
|
35500
|
-
|
|
35501
|
-
}
|
|
35502
|
-
},
|
|
35503
|
-
DLPRoot: {
|
|
35504
|
-
addresses: {
|
|
35505
|
-
14800: "0xff14346dF2B8Fd0c95BF34f1c92e49417b508AD5",
|
|
35506
|
-
1480: "0xff14346dF2B8Fd0c95BF34f1c92e49417b508AD5"
|
|
35507
|
-
}
|
|
35508
|
-
},
|
|
35509
|
-
DLPRootMetrics: {
|
|
35510
|
-
addresses: {
|
|
35511
|
-
14800: "0xbb532917B6407c060Afd9Cb7d53527eCb91d6662",
|
|
35512
|
-
1480: "0xbb532917B6407c060Afd9Cb7d53527eCb91d6662"
|
|
35815
|
+
/**
|
|
35816
|
+
* Waits for transaction confirmation and returns the receipt.
|
|
35817
|
+
* Results are memoized - multiple calls return the same promise.
|
|
35818
|
+
*
|
|
35819
|
+
* @param options Optional timeout configuration
|
|
35820
|
+
* @param options.timeout Timeout in milliseconds (default: 30000)
|
|
35821
|
+
* @returns Transaction receipt with gas usage, logs, and status
|
|
35822
|
+
*/
|
|
35823
|
+
async waitForReceipt(options) {
|
|
35824
|
+
if (this._receipt) {
|
|
35825
|
+
return this._receipt;
|
|
35826
|
+
}
|
|
35827
|
+
if (!this._receiptPromise) {
|
|
35828
|
+
this._receiptPromise = this.context.publicClient.waitForTransactionReceipt({
|
|
35829
|
+
hash: this.hash,
|
|
35830
|
+
timeout: options?.timeout ?? 3e4
|
|
35831
|
+
}).then((receipt) => {
|
|
35832
|
+
this._receipt = receipt;
|
|
35833
|
+
return receipt;
|
|
35834
|
+
});
|
|
35513
35835
|
}
|
|
35514
|
-
|
|
35515
|
-
|
|
35516
|
-
|
|
35517
|
-
|
|
35518
|
-
|
|
35836
|
+
return this._receiptPromise;
|
|
35837
|
+
}
|
|
35838
|
+
/**
|
|
35839
|
+
* Waits for transaction confirmation and parses emitted events.
|
|
35840
|
+
* Results are memoized - multiple calls return the same promise.
|
|
35841
|
+
*
|
|
35842
|
+
* @returns Parsed event data with transaction metadata
|
|
35843
|
+
* @throws {Error} If no operation was specified for event parsing
|
|
35844
|
+
*/
|
|
35845
|
+
async waitForEvents() {
|
|
35846
|
+
if (this._eventData) {
|
|
35847
|
+
return this._eventData;
|
|
35519
35848
|
}
|
|
35520
|
-
|
|
35521
|
-
|
|
35522
|
-
|
|
35523
|
-
|
|
35524
|
-
|
|
35849
|
+
if (!this._eventPromise) {
|
|
35850
|
+
if (!this.operation) {
|
|
35851
|
+
throw new Error(
|
|
35852
|
+
"Cannot parse events: no operation specified. Use waitForReceipt() instead or ensure the operation is configured."
|
|
35853
|
+
);
|
|
35854
|
+
}
|
|
35855
|
+
this._eventPromise = parseTransactionResult(
|
|
35856
|
+
this.context,
|
|
35857
|
+
this.hash,
|
|
35858
|
+
this.operation
|
|
35859
|
+
).then((eventData) => {
|
|
35860
|
+
this._eventData = eventData;
|
|
35861
|
+
return eventData;
|
|
35862
|
+
});
|
|
35525
35863
|
}
|
|
35864
|
+
return this._eventPromise;
|
|
35526
35865
|
}
|
|
35527
|
-
|
|
35528
|
-
|
|
35529
|
-
|
|
35530
|
-
|
|
35531
|
-
|
|
35532
|
-
|
|
35533
|
-
|
|
35534
|
-
|
|
35535
|
-
|
|
35536
|
-
|
|
35537
|
-
|
|
35538
|
-
|
|
35539
|
-
|
|
35540
|
-
},
|
|
35541
|
-
1480: {
|
|
35542
|
-
Multicall3: CONTRACTS.Multicall3.addresses[1480],
|
|
35543
|
-
Multisend: CONTRACTS.Multisend.addresses[1480]
|
|
35866
|
+
/**
|
|
35867
|
+
* Enables string coercion for backwards compatibility.
|
|
35868
|
+
* Allows TransactionHandle to be used anywhere a Hash is expected.
|
|
35869
|
+
*
|
|
35870
|
+
* @example
|
|
35871
|
+
* ```typescript
|
|
35872
|
+
* const hash: Hash = tx; // Works via toString()
|
|
35873
|
+
* console.log(`Transaction: ${tx}`); // Prints hash
|
|
35874
|
+
* ```
|
|
35875
|
+
* @returns The transaction hash as a string
|
|
35876
|
+
*/
|
|
35877
|
+
toString() {
|
|
35878
|
+
return this.hash;
|
|
35544
35879
|
}
|
|
35545
|
-
|
|
35546
|
-
|
|
35547
|
-
|
|
35548
|
-
|
|
35549
|
-
|
|
35550
|
-
|
|
35551
|
-
|
|
35552
|
-
|
|
35553
|
-
}
|
|
35554
|
-
|
|
35555
|
-
|
|
35556
|
-
|
|
35557
|
-
|
|
35558
|
-
|
|
35559
|
-
|
|
35880
|
+
/**
|
|
35881
|
+
* JSON serialization support.
|
|
35882
|
+
* Returns the hash when serialized to JSON.
|
|
35883
|
+
*
|
|
35884
|
+
* @returns The transaction hash for JSON serialization
|
|
35885
|
+
*/
|
|
35886
|
+
toJSON() {
|
|
35887
|
+
return this.hash;
|
|
35888
|
+
}
|
|
35889
|
+
/**
|
|
35890
|
+
* Custom inspect for Node.js console.log
|
|
35891
|
+
*
|
|
35892
|
+
* @returns Formatted string representation for debugging
|
|
35893
|
+
*/
|
|
35894
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
35895
|
+
return `TransactionHandle { hash: '${this.hash}', operation: '${this.operation ?? "none"}' }`;
|
|
35560
35896
|
}
|
|
35561
|
-
return contractAddress;
|
|
35562
35897
|
};
|
|
35563
35898
|
|
|
35564
35899
|
// src/utils/grantFiles.ts
|
|
@@ -36190,31 +36525,32 @@ var PermissionsController = class {
|
|
|
36190
36525
|
* ```
|
|
36191
36526
|
*/
|
|
36192
36527
|
async grant(params) {
|
|
36193
|
-
const
|
|
36194
|
-
return
|
|
36528
|
+
const txHandle = await this.submitPermissionGrant(params);
|
|
36529
|
+
return await txHandle.waitForEvents();
|
|
36195
36530
|
}
|
|
36196
36531
|
/**
|
|
36197
|
-
* Submits a permission grant transaction and returns
|
|
36532
|
+
* Submits a permission grant transaction and returns a handle for flexible result access.
|
|
36198
36533
|
*
|
|
36199
|
-
*
|
|
36200
|
-
*
|
|
36201
|
-
*
|
|
36534
|
+
* @remarks
|
|
36535
|
+
* This lower-level method provides maximum control over transaction timing.
|
|
36536
|
+
* Returns a TransactionHandle that allows immediate hash access or optional event parsing.
|
|
36537
|
+
* Use this when handling multiple transactions or when you need granular control.
|
|
36202
36538
|
*
|
|
36203
36539
|
* @param params - The permission grant configuration object
|
|
36204
|
-
* @returns Promise
|
|
36540
|
+
* @returns Promise resolving to TransactionHandle with hash and event parsing capabilities
|
|
36205
36541
|
* @throws {RelayerError} When gasless transaction submission fails
|
|
36206
36542
|
* @throws {SignatureError} When user rejects the signature request
|
|
36207
36543
|
* @throws {SerializationError} When grant data cannot be serialized
|
|
36208
36544
|
* @throws {BlockchainError} When permission grant preparation fails
|
|
36209
36545
|
* @example
|
|
36210
36546
|
* ```typescript
|
|
36211
|
-
* // Submit transaction and
|
|
36212
|
-
* const
|
|
36213
|
-
* console.log(`Transaction submitted: ${
|
|
36547
|
+
* // Submit transaction and get immediate hash access
|
|
36548
|
+
* const tx = await vana.permissions.submitPermissionGrant(params);
|
|
36549
|
+
* console.log(`Transaction submitted: ${tx.hash}`);
|
|
36214
36550
|
*
|
|
36215
|
-
* //
|
|
36216
|
-
* const
|
|
36217
|
-
* console.log(`Permission ID: ${
|
|
36551
|
+
* // Optionally wait for and parse events
|
|
36552
|
+
* const eventData = await tx.waitForEvents();
|
|
36553
|
+
* console.log(`Permission ID: ${eventData.permissionId}`);
|
|
36218
36554
|
* ```
|
|
36219
36555
|
*/
|
|
36220
36556
|
async submitPermissionGrant(params) {
|
|
@@ -36272,12 +36608,18 @@ var PermissionsController = class {
|
|
|
36272
36608
|
}
|
|
36273
36609
|
}
|
|
36274
36610
|
/**
|
|
36275
|
-
*
|
|
36276
|
-
*
|
|
36611
|
+
* Completes the grant process after user confirmation.
|
|
36612
|
+
*
|
|
36613
|
+
* @remarks
|
|
36614
|
+
* This internal method is called by the confirm() function returned from prepareGrant().
|
|
36615
|
+
* It handles IPFS upload, signature creation, and transaction submission.
|
|
36277
36616
|
*
|
|
36278
36617
|
* @param params - The permission grant parameters containing user and operation details
|
|
36279
36618
|
* @param grantFile - The prepared grant file with permissions and metadata
|
|
36280
|
-
* @returns Promise resolving to
|
|
36619
|
+
* @returns Promise resolving to TransactionHandle for flexible result access
|
|
36620
|
+
* @throws {BlockchainError} When permission grant confirmation fails
|
|
36621
|
+
* @throws {NetworkError} When IPFS upload fails
|
|
36622
|
+
* @throws {SignatureError} When user rejects the signature
|
|
36281
36623
|
*/
|
|
36282
36624
|
async confirmGrantInternal(params, grantFile) {
|
|
36283
36625
|
try {
|
|
@@ -36466,14 +36808,20 @@ var PermissionsController = class {
|
|
|
36466
36808
|
2
|
|
36467
36809
|
)
|
|
36468
36810
|
);
|
|
36811
|
+
let hash;
|
|
36469
36812
|
if (this.context.relayerCallbacks?.submitPermissionGrant) {
|
|
36470
|
-
|
|
36813
|
+
hash = await this.context.relayerCallbacks.submitPermissionGrant(
|
|
36471
36814
|
typedData,
|
|
36472
36815
|
signature
|
|
36473
36816
|
);
|
|
36474
36817
|
} else {
|
|
36475
|
-
|
|
36818
|
+
hash = await this.submitDirectTransaction(typedData, signature);
|
|
36476
36819
|
}
|
|
36820
|
+
return new TransactionHandle(
|
|
36821
|
+
this.context,
|
|
36822
|
+
hash,
|
|
36823
|
+
"grant"
|
|
36824
|
+
);
|
|
36477
36825
|
} catch (error) {
|
|
36478
36826
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
36479
36827
|
throw error;
|
|
@@ -36486,11 +36834,24 @@ var PermissionsController = class {
|
|
|
36486
36834
|
}
|
|
36487
36835
|
/**
|
|
36488
36836
|
* Submits an already-signed trust server transaction to the blockchain.
|
|
36837
|
+
*
|
|
36838
|
+
* @remarks
|
|
36489
36839
|
* This method extracts the trust server input from typed data and submits it directly.
|
|
36840
|
+
* Used internally by trust server methods after signature collection.
|
|
36490
36841
|
*
|
|
36491
36842
|
* @param typedData - The EIP-712 typed data for TrustServer
|
|
36492
|
-
* @param signature - The user's signature
|
|
36493
|
-
* @returns Promise resolving to
|
|
36843
|
+
* @param signature - The user's signature obtained via `signTypedData()`
|
|
36844
|
+
* @returns Promise resolving to TransactionHandle for transaction tracking
|
|
36845
|
+
* @throws {BlockchainError} When contract submission fails
|
|
36846
|
+
* @throws {NetworkError} When blockchain communication fails
|
|
36847
|
+
* @example
|
|
36848
|
+
* ```typescript
|
|
36849
|
+
* const txHandle = await vana.permissions.submitSignedTrustServer(
|
|
36850
|
+
* typedData,
|
|
36851
|
+
* "0x1234..."
|
|
36852
|
+
* );
|
|
36853
|
+
* const result = await txHandle.waitForEvents();
|
|
36854
|
+
* ```
|
|
36494
36855
|
*/
|
|
36495
36856
|
async submitSignedTrustServer(typedData, signature) {
|
|
36496
36857
|
try {
|
|
@@ -36498,10 +36859,15 @@ var PermissionsController = class {
|
|
|
36498
36859
|
nonce: BigInt(typedData.message.nonce),
|
|
36499
36860
|
serverId: typedData.message.serverId
|
|
36500
36861
|
};
|
|
36501
|
-
|
|
36862
|
+
const hash = await this.submitTrustServerTransaction(
|
|
36502
36863
|
trustServerInput,
|
|
36503
36864
|
signature
|
|
36504
36865
|
);
|
|
36866
|
+
return new TransactionHandle(
|
|
36867
|
+
this.context,
|
|
36868
|
+
hash,
|
|
36869
|
+
"trustServer"
|
|
36870
|
+
);
|
|
36505
36871
|
} catch (error) {
|
|
36506
36872
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
36507
36873
|
throw error;
|
|
@@ -36528,11 +36894,24 @@ var PermissionsController = class {
|
|
|
36528
36894
|
}
|
|
36529
36895
|
/**
|
|
36530
36896
|
* Submits an already-signed add and trust server transaction to the blockchain.
|
|
36897
|
+
*
|
|
36898
|
+
* @remarks
|
|
36531
36899
|
* This method extracts the add and trust server input from typed data and submits it directly.
|
|
36900
|
+
* Combines server registration and trust operations in a single transaction.
|
|
36532
36901
|
*
|
|
36533
36902
|
* @param typedData - The EIP-712 typed data for AddAndTrustServer
|
|
36534
|
-
* @param signature - The user's signature
|
|
36535
|
-
* @returns Promise resolving to
|
|
36903
|
+
* @param signature - The user's signature obtained via `signTypedData()`
|
|
36904
|
+
* @returns Promise resolving to TransactionHandle for transaction tracking
|
|
36905
|
+
* @throws {BlockchainError} When contract submission fails
|
|
36906
|
+
* @throws {NetworkError} When blockchain communication fails
|
|
36907
|
+
* @example
|
|
36908
|
+
* ```typescript
|
|
36909
|
+
* const txHandle = await vana.permissions.submitSignedAddAndTrustServer(
|
|
36910
|
+
* typedData,
|
|
36911
|
+
* "0x1234..."
|
|
36912
|
+
* );
|
|
36913
|
+
* const result = await txHandle.waitForEvents();
|
|
36914
|
+
* ```
|
|
36536
36915
|
*/
|
|
36537
36916
|
async submitSignedAddAndTrustServer(typedData, signature) {
|
|
36538
36917
|
try {
|
|
@@ -36542,10 +36921,15 @@ var PermissionsController = class {
|
|
|
36542
36921
|
serverUrl: typedData.message.serverUrl,
|
|
36543
36922
|
publicKey: typedData.message.publicKey
|
|
36544
36923
|
};
|
|
36545
|
-
|
|
36924
|
+
const hash = await this.submitAddAndTrustServerTransaction(
|
|
36546
36925
|
addAndTrustServerInput,
|
|
36547
36926
|
signature
|
|
36548
36927
|
);
|
|
36928
|
+
return new TransactionHandle(
|
|
36929
|
+
this.context,
|
|
36930
|
+
hash,
|
|
36931
|
+
"addAndTrustServer"
|
|
36932
|
+
);
|
|
36549
36933
|
} catch (error) {
|
|
36550
36934
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
36551
36935
|
throw error;
|
|
@@ -36558,22 +36942,41 @@ var PermissionsController = class {
|
|
|
36558
36942
|
}
|
|
36559
36943
|
/**
|
|
36560
36944
|
* Submits an already-signed permission revoke transaction to the blockchain.
|
|
36945
|
+
*
|
|
36946
|
+
* @remarks
|
|
36561
36947
|
* This method handles the revocation of previously granted permissions.
|
|
36948
|
+
* Used internally by revocation methods after signature collection.
|
|
36562
36949
|
*
|
|
36563
36950
|
* @param typedData - The EIP-712 typed data for PermissionRevoke
|
|
36564
|
-
* @param signature - The user's signature
|
|
36565
|
-
* @returns Promise resolving to
|
|
36951
|
+
* @param signature - The user's signature obtained via `signTypedData()`
|
|
36952
|
+
* @returns Promise resolving to TransactionHandle for transaction tracking
|
|
36953
|
+
* @throws {BlockchainError} When contract submission fails
|
|
36954
|
+
* @throws {NetworkError} When blockchain communication fails
|
|
36955
|
+
* @example
|
|
36956
|
+
* ```typescript
|
|
36957
|
+
* const txHandle = await vana.permissions.submitSignedRevoke(
|
|
36958
|
+
* typedData,
|
|
36959
|
+
* "0x1234..."
|
|
36960
|
+
* );
|
|
36961
|
+
* const result = await txHandle.waitForEvents();
|
|
36962
|
+
* ```
|
|
36566
36963
|
*/
|
|
36567
36964
|
async submitSignedRevoke(typedData, signature) {
|
|
36568
36965
|
try {
|
|
36966
|
+
let hash;
|
|
36569
36967
|
if (this.context.relayerCallbacks?.submitPermissionRevoke) {
|
|
36570
|
-
|
|
36968
|
+
hash = await this.context.relayerCallbacks.submitPermissionRevoke(
|
|
36571
36969
|
typedData,
|
|
36572
36970
|
signature
|
|
36573
36971
|
);
|
|
36574
36972
|
} else {
|
|
36575
|
-
|
|
36973
|
+
hash = await this.submitDirectRevokeTransaction(typedData, signature);
|
|
36576
36974
|
}
|
|
36975
|
+
return new TransactionHandle(
|
|
36976
|
+
this.context,
|
|
36977
|
+
hash,
|
|
36978
|
+
"revoke"
|
|
36979
|
+
);
|
|
36577
36980
|
} catch (error) {
|
|
36578
36981
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
36579
36982
|
throw error;
|
|
@@ -36586,22 +36989,41 @@ var PermissionsController = class {
|
|
|
36586
36989
|
}
|
|
36587
36990
|
/**
|
|
36588
36991
|
* Submits an already-signed untrust server transaction to the blockchain.
|
|
36992
|
+
*
|
|
36993
|
+
* @remarks
|
|
36589
36994
|
* This method handles the removal of trusted servers.
|
|
36995
|
+
* Used internally by untrust server methods after signature collection.
|
|
36590
36996
|
*
|
|
36591
36997
|
* @param typedData - The EIP-712 typed data for UntrustServer
|
|
36592
|
-
* @param signature - The user's signature
|
|
36593
|
-
* @returns Promise resolving to
|
|
36998
|
+
* @param signature - The user's signature obtained via `signTypedData()`
|
|
36999
|
+
* @returns Promise resolving to TransactionHandle for transaction tracking
|
|
37000
|
+
* @throws {BlockchainError} When contract submission fails
|
|
37001
|
+
* @throws {NetworkError} When blockchain communication fails
|
|
37002
|
+
* @example
|
|
37003
|
+
* ```typescript
|
|
37004
|
+
* const txHandle = await vana.permissions.submitSignedUntrustServer(
|
|
37005
|
+
* typedData,
|
|
37006
|
+
* "0x1234..."
|
|
37007
|
+
* );
|
|
37008
|
+
* const result = await txHandle.waitForEvents();
|
|
37009
|
+
* ```
|
|
36594
37010
|
*/
|
|
36595
37011
|
async submitSignedUntrustServer(typedData, signature) {
|
|
36596
37012
|
try {
|
|
37013
|
+
let hash;
|
|
36597
37014
|
if (this.context.relayerCallbacks?.submitUntrustServer) {
|
|
36598
|
-
|
|
37015
|
+
hash = await this.context.relayerCallbacks.submitUntrustServer(
|
|
36599
37016
|
typedData,
|
|
36600
37017
|
signature
|
|
36601
37018
|
);
|
|
36602
37019
|
} else {
|
|
36603
|
-
|
|
37020
|
+
hash = await this.submitSignedUntrustTransaction(typedData, signature);
|
|
36604
37021
|
}
|
|
37022
|
+
return new TransactionHandle(
|
|
37023
|
+
this.context,
|
|
37024
|
+
hash,
|
|
37025
|
+
"untrustServer"
|
|
37026
|
+
);
|
|
36605
37027
|
} catch (error) {
|
|
36606
37028
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
36607
37029
|
throw error;
|
|
@@ -36615,9 +37037,14 @@ var PermissionsController = class {
|
|
|
36615
37037
|
/**
|
|
36616
37038
|
* Submits a signed transaction directly to the blockchain.
|
|
36617
37039
|
*
|
|
37040
|
+
* @remarks
|
|
37041
|
+
* Internal method used when relayer callbacks are not available. Formats the signature
|
|
37042
|
+
* and submits the permission grant directly to the smart contract.
|
|
37043
|
+
*
|
|
36618
37044
|
* @param typedData - The typed data structure for the permission grant
|
|
36619
37045
|
* @param signature - The cryptographic signature authorizing the transaction
|
|
36620
37046
|
* @returns Promise resolving to the transaction hash
|
|
37047
|
+
* @throws {BlockchainError} When contract submission fails
|
|
36621
37048
|
*/
|
|
36622
37049
|
async submitDirectTransaction(typedData, signature) {
|
|
36623
37050
|
const chainId = await this.context.walletClient.getChainId();
|
|
@@ -36678,8 +37105,8 @@ var PermissionsController = class {
|
|
|
36678
37105
|
* ```
|
|
36679
37106
|
*/
|
|
36680
37107
|
async revoke(params) {
|
|
36681
|
-
const
|
|
36682
|
-
return
|
|
37108
|
+
const txHandle = await this.submitPermissionRevoke(params);
|
|
37109
|
+
return await txHandle.waitForEvents();
|
|
36683
37110
|
}
|
|
36684
37111
|
/**
|
|
36685
37112
|
* Submits a permission revocation transaction and returns the transaction hash immediately.
|
|
@@ -36721,7 +37148,11 @@ var PermissionsController = class {
|
|
|
36721
37148
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
36722
37149
|
chain: this.context.walletClient.chain || null
|
|
36723
37150
|
});
|
|
36724
|
-
return
|
|
37151
|
+
return new TransactionHandle(
|
|
37152
|
+
this.context,
|
|
37153
|
+
txHash,
|
|
37154
|
+
"revoke"
|
|
37155
|
+
);
|
|
36725
37156
|
} catch (error) {
|
|
36726
37157
|
if (error instanceof Error) {
|
|
36727
37158
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -36736,15 +37167,29 @@ var PermissionsController = class {
|
|
|
36736
37167
|
}
|
|
36737
37168
|
}
|
|
36738
37169
|
/**
|
|
36739
|
-
* Revokes a permission with a signature
|
|
37170
|
+
* Revokes a permission with a signature for gasless transactions.
|
|
37171
|
+
*
|
|
37172
|
+
* @remarks
|
|
37173
|
+
* This method creates an EIP-712 signature for permission revocation and submits
|
|
37174
|
+
* it either through relayer callbacks or directly to the blockchain. Provides
|
|
37175
|
+
* gasless revocation when relayer is configured.
|
|
36740
37176
|
*
|
|
36741
37177
|
* @param params - Parameters for revoking the permission
|
|
36742
|
-
* @
|
|
37178
|
+
* @param params.permissionId - Permission identifier to revoke (accepts bigint, number, or string)
|
|
37179
|
+
* @returns Promise resolving to TransactionHandle for transaction tracking
|
|
36743
37180
|
* @throws {BlockchainError} When chain ID is not available
|
|
36744
37181
|
* @throws {NonceError} When retrieving user nonce fails
|
|
36745
37182
|
* @throws {SignatureError} When user rejects the signature request
|
|
36746
37183
|
* @throws {RelayerError} When gasless submission fails
|
|
36747
37184
|
* @throws {PermissionError} When revocation fails for any other reason
|
|
37185
|
+
* @example
|
|
37186
|
+
* ```typescript
|
|
37187
|
+
* const txHandle = await vana.permissions.submitRevokeWithSignature({
|
|
37188
|
+
* permissionId: 123n
|
|
37189
|
+
* });
|
|
37190
|
+
* const result = await txHandle.waitForEvents();
|
|
37191
|
+
* console.log(`Permission ${result.permissionId} revoked`);
|
|
37192
|
+
* ```
|
|
36748
37193
|
*/
|
|
36749
37194
|
async submitRevokeWithSignature(params) {
|
|
36750
37195
|
try {
|
|
@@ -36768,14 +37213,20 @@ var PermissionsController = class {
|
|
|
36768
37213
|
message: revokePermissionInput
|
|
36769
37214
|
};
|
|
36770
37215
|
const signature = await this.signTypedData(typedData);
|
|
37216
|
+
let hash;
|
|
36771
37217
|
if (this.context.relayerCallbacks?.submitPermissionRevoke) {
|
|
36772
|
-
|
|
37218
|
+
hash = await this.context.relayerCallbacks.submitPermissionRevoke(
|
|
36773
37219
|
typedData,
|
|
36774
37220
|
signature
|
|
36775
37221
|
);
|
|
36776
37222
|
} else {
|
|
36777
|
-
|
|
37223
|
+
hash = await this.submitDirectRevokeTransaction(typedData, signature);
|
|
36778
37224
|
}
|
|
37225
|
+
return new TransactionHandle(
|
|
37226
|
+
this.context,
|
|
37227
|
+
hash,
|
|
37228
|
+
"revoke"
|
|
37229
|
+
);
|
|
36779
37230
|
} catch (error) {
|
|
36780
37231
|
throw new PermissionError(
|
|
36781
37232
|
`Failed to revoke permission with signature: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -36807,6 +37258,18 @@ var PermissionsController = class {
|
|
|
36807
37258
|
* const serversNonce = await this.getServersUserNonce();
|
|
36808
37259
|
* ```
|
|
36809
37260
|
*/
|
|
37261
|
+
/**
|
|
37262
|
+
* @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
|
|
37263
|
+
*
|
|
37264
|
+
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
37265
|
+
*
|
|
37266
|
+
* @remarks
|
|
37267
|
+
* This method is deprecated in favor of more specific nonce methods that target
|
|
37268
|
+
* the appropriate contract for the operation being performed.
|
|
37269
|
+
*
|
|
37270
|
+
* @returns Promise resolving to the user's current nonce as a bigint
|
|
37271
|
+
* @throws {NonceError} When retrieving the nonce fails
|
|
37272
|
+
*/
|
|
36810
37273
|
async getUserNonce() {
|
|
36811
37274
|
try {
|
|
36812
37275
|
const userAddress = await this.getUserAddress();
|
|
@@ -36843,6 +37306,16 @@ var PermissionsController = class {
|
|
|
36843
37306
|
* console.log(`Current servers nonce: ${nonce}`);
|
|
36844
37307
|
* ```
|
|
36845
37308
|
*/
|
|
37309
|
+
/**
|
|
37310
|
+
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
37311
|
+
*
|
|
37312
|
+
* @remarks
|
|
37313
|
+
* Used for server-related operations (trust/untrust) to prevent replay attacks.
|
|
37314
|
+
* The nonce must be incremented with each server operation.
|
|
37315
|
+
*
|
|
37316
|
+
* @returns Promise resolving to the user's current nonce as a bigint
|
|
37317
|
+
* @throws {NonceError} When retrieving the nonce fails
|
|
37318
|
+
*/
|
|
36846
37319
|
async getServersUserNonce() {
|
|
36847
37320
|
try {
|
|
36848
37321
|
const userAddress = await this.getUserAddress();
|
|
@@ -36879,6 +37352,16 @@ var PermissionsController = class {
|
|
|
36879
37352
|
* console.log(`Current permissions nonce: ${nonce}`);
|
|
36880
37353
|
* ```
|
|
36881
37354
|
*/
|
|
37355
|
+
/**
|
|
37356
|
+
* Retrieves the user's current nonce from the DataPortabilityPermissions contract.
|
|
37357
|
+
*
|
|
37358
|
+
* @remarks
|
|
37359
|
+
* Used for permission-related operations (grant/revoke) to prevent replay attacks.
|
|
37360
|
+
* The nonce must be incremented with each permission operation.
|
|
37361
|
+
*
|
|
37362
|
+
* @returns Promise resolving to the user's current nonce as a bigint
|
|
37363
|
+
* @throws {NonceError} When retrieving the nonce fails
|
|
37364
|
+
*/
|
|
36882
37365
|
async getPermissionsUserNonce() {
|
|
36883
37366
|
try {
|
|
36884
37367
|
const userAddress = await this.getUserAddress();
|
|
@@ -37284,7 +37767,11 @@ var PermissionsController = class {
|
|
|
37284
37767
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
37285
37768
|
chain: this.context.walletClient.chain || null
|
|
37286
37769
|
});
|
|
37287
|
-
return
|
|
37770
|
+
return new TransactionHandle(
|
|
37771
|
+
this.context,
|
|
37772
|
+
txHash,
|
|
37773
|
+
"addAndTrustServer"
|
|
37774
|
+
);
|
|
37288
37775
|
} catch (error) {
|
|
37289
37776
|
if (error instanceof Error && error.message.includes("rejected")) {
|
|
37290
37777
|
throw new UserRejectedRequestError();
|
|
@@ -37318,7 +37805,11 @@ var PermissionsController = class {
|
|
|
37318
37805
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
37319
37806
|
chain: this.context.walletClient.chain || null
|
|
37320
37807
|
});
|
|
37321
|
-
return
|
|
37808
|
+
return new TransactionHandle(
|
|
37809
|
+
this.context,
|
|
37810
|
+
txHash,
|
|
37811
|
+
"trustServer"
|
|
37812
|
+
);
|
|
37322
37813
|
} catch (error) {
|
|
37323
37814
|
if (error instanceof Error && error.message.includes("rejected")) {
|
|
37324
37815
|
throw new UserRejectedRequestError();
|
|
@@ -37333,7 +37824,7 @@ var PermissionsController = class {
|
|
|
37333
37824
|
* Adds and trusts a server using a signature (gasless transaction).
|
|
37334
37825
|
*
|
|
37335
37826
|
* @param params - Parameters for adding and trusting the server
|
|
37336
|
-
* @returns Promise resolving to
|
|
37827
|
+
* @returns Promise resolving to TransactionHandle with ServerTrustResult event data
|
|
37337
37828
|
*/
|
|
37338
37829
|
async submitAddAndTrustServerWithSignature(params) {
|
|
37339
37830
|
try {
|
|
@@ -37357,17 +37848,23 @@ var PermissionsController = class {
|
|
|
37357
37848
|
});
|
|
37358
37849
|
const signature = await this.signTypedData(typedData);
|
|
37359
37850
|
console.debug("\u{1F50D} Generated signature:", signature);
|
|
37851
|
+
let hash;
|
|
37360
37852
|
if (this.context.relayerCallbacks?.submitAddAndTrustServer) {
|
|
37361
|
-
|
|
37853
|
+
hash = await this.context.relayerCallbacks.submitAddAndTrustServer(
|
|
37362
37854
|
typedData,
|
|
37363
37855
|
signature
|
|
37364
37856
|
);
|
|
37365
37857
|
} else {
|
|
37366
|
-
|
|
37858
|
+
hash = await this.submitAddAndTrustServerTransaction(
|
|
37367
37859
|
addAndTrustServerInput,
|
|
37368
37860
|
signature
|
|
37369
37861
|
);
|
|
37370
37862
|
}
|
|
37863
|
+
return new TransactionHandle(
|
|
37864
|
+
this.context,
|
|
37865
|
+
hash,
|
|
37866
|
+
"addAndTrustServer"
|
|
37867
|
+
);
|
|
37371
37868
|
} catch (error) {
|
|
37372
37869
|
if (error instanceof Error) {
|
|
37373
37870
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -37405,17 +37902,23 @@ var PermissionsController = class {
|
|
|
37405
37902
|
};
|
|
37406
37903
|
const typedData = await this.composeTrustServerMessage(trustServerInput);
|
|
37407
37904
|
const signature = await this.signTypedData(typedData);
|
|
37905
|
+
let hash;
|
|
37408
37906
|
if (this.context.relayerCallbacks?.submitTrustServer) {
|
|
37409
|
-
|
|
37907
|
+
hash = await this.context.relayerCallbacks.submitTrustServer(
|
|
37410
37908
|
typedData,
|
|
37411
37909
|
signature
|
|
37412
37910
|
);
|
|
37413
37911
|
} else {
|
|
37414
|
-
|
|
37912
|
+
hash = await this.submitTrustServerTransaction(
|
|
37415
37913
|
trustServerInput,
|
|
37416
37914
|
signature
|
|
37417
37915
|
);
|
|
37418
37916
|
}
|
|
37917
|
+
return new TransactionHandle(
|
|
37918
|
+
this.context,
|
|
37919
|
+
hash,
|
|
37920
|
+
"trustServer"
|
|
37921
|
+
);
|
|
37419
37922
|
} catch (error) {
|
|
37420
37923
|
if (error instanceof Error) {
|
|
37421
37924
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -37435,6 +37938,17 @@ var PermissionsController = class {
|
|
|
37435
37938
|
* @param params - The untrust server parameters containing server details
|
|
37436
37939
|
* @returns Promise resolving to the transaction hash
|
|
37437
37940
|
*/
|
|
37941
|
+
/**
|
|
37942
|
+
* Submits an untrust server transaction directly to the blockchain.
|
|
37943
|
+
*
|
|
37944
|
+
* @remarks
|
|
37945
|
+
* Internal method used for direct blockchain submission of untrust server operations
|
|
37946
|
+
* when relayer callbacks are not available.
|
|
37947
|
+
*
|
|
37948
|
+
* @param params - The untrust server parameters
|
|
37949
|
+
* @returns Promise resolving to TransactionHandle for transaction tracking
|
|
37950
|
+
* @throws {BlockchainError} When contract submission fails
|
|
37951
|
+
*/
|
|
37438
37952
|
async submitDirectUntrustTransaction(params) {
|
|
37439
37953
|
try {
|
|
37440
37954
|
const chainId = await this.context.walletClient.getChainId();
|
|
@@ -37451,7 +37965,11 @@ var PermissionsController = class {
|
|
|
37451
37965
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
37452
37966
|
chain: this.context.walletClient.chain || null
|
|
37453
37967
|
});
|
|
37454
|
-
return
|
|
37968
|
+
return new TransactionHandle(
|
|
37969
|
+
this.context,
|
|
37970
|
+
txHash,
|
|
37971
|
+
"untrustServer"
|
|
37972
|
+
);
|
|
37455
37973
|
} catch (error) {
|
|
37456
37974
|
if (error instanceof Error && error.message.includes("rejected")) {
|
|
37457
37975
|
throw new UserRejectedRequestError();
|
|
@@ -37519,14 +38037,20 @@ var PermissionsController = class {
|
|
|
37519
38037
|
};
|
|
37520
38038
|
const typedData = await this.composeUntrustServerMessage(untrustServerInput);
|
|
37521
38039
|
const signature = await this.signTypedData(typedData);
|
|
38040
|
+
let hash;
|
|
37522
38041
|
if (this.context.relayerCallbacks?.submitUntrustServer) {
|
|
37523
|
-
|
|
38042
|
+
hash = await this.context.relayerCallbacks.submitUntrustServer(
|
|
37524
38043
|
typedData,
|
|
37525
38044
|
signature
|
|
37526
38045
|
);
|
|
37527
38046
|
} else {
|
|
37528
|
-
|
|
38047
|
+
hash = await this.submitSignedUntrustTransaction(typedData, signature);
|
|
37529
38048
|
}
|
|
38049
|
+
return new TransactionHandle(
|
|
38050
|
+
this.context,
|
|
38051
|
+
hash,
|
|
38052
|
+
"untrustServer"
|
|
38053
|
+
);
|
|
37530
38054
|
} catch (error) {
|
|
37531
38055
|
if (error instanceof Error) {
|
|
37532
38056
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -37650,18 +38174,19 @@ var PermissionsController = class {
|
|
|
37650
38174
|
};
|
|
37651
38175
|
}
|
|
37652
38176
|
const endIndex = Math.min(offset + limit, total);
|
|
37653
|
-
const
|
|
38177
|
+
const serverIdCalls = [];
|
|
37654
38178
|
for (let i = offset; i < endIndex; i++) {
|
|
37655
|
-
|
|
38179
|
+
serverIdCalls.push({
|
|
37656
38180
|
address: DataPortabilityServersAddress,
|
|
37657
38181
|
abi: DataPortabilityServersAbi,
|
|
37658
38182
|
functionName: "userServerIdsAt",
|
|
37659
38183
|
args: [user, BigInt(i)]
|
|
37660
38184
|
});
|
|
37661
|
-
serverPromises.push(promise);
|
|
37662
38185
|
}
|
|
37663
|
-
const
|
|
37664
|
-
|
|
38186
|
+
const serverIdResults = await gasAwareMulticall(this.context.publicClient, {
|
|
38187
|
+
contracts: serverIdCalls
|
|
38188
|
+
});
|
|
38189
|
+
const servers = serverIdResults.map((result) => Number(result)).filter((id) => id > 0);
|
|
37665
38190
|
return {
|
|
37666
38191
|
servers,
|
|
37667
38192
|
total,
|
|
@@ -37686,35 +38211,51 @@ var PermissionsController = class {
|
|
|
37686
38211
|
async getTrustedServersWithInfo(options = {}) {
|
|
37687
38212
|
try {
|
|
37688
38213
|
const paginatedResult = await this.getTrustedServersPaginated(options);
|
|
37689
|
-
const
|
|
37690
|
-
|
|
37691
|
-
|
|
37692
|
-
|
|
37693
|
-
|
|
37694
|
-
|
|
37695
|
-
|
|
37696
|
-
|
|
37697
|
-
|
|
37698
|
-
|
|
37699
|
-
|
|
37700
|
-
|
|
37701
|
-
|
|
37702
|
-
// 0 means still active
|
|
37703
|
-
};
|
|
37704
|
-
} catch {
|
|
37705
|
-
return {
|
|
37706
|
-
id: BigInt(serverId),
|
|
37707
|
-
owner: "0x0000000000000000000000000000000000000000",
|
|
37708
|
-
serverAddress: "0x0000000000000000000000000000000000000000",
|
|
37709
|
-
publicKey: "",
|
|
37710
|
-
url: "",
|
|
37711
|
-
startBlock: 0n,
|
|
37712
|
-
endBlock: 0n
|
|
37713
|
-
};
|
|
37714
|
-
}
|
|
37715
|
-
}
|
|
38214
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
38215
|
+
const DataPortabilityServersAddress = getContractAddress(
|
|
38216
|
+
chainId,
|
|
38217
|
+
"DataPortabilityServers"
|
|
38218
|
+
);
|
|
38219
|
+
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
38220
|
+
const serverInfoCalls = paginatedResult.servers.map(
|
|
38221
|
+
(serverId) => ({
|
|
38222
|
+
address: DataPortabilityServersAddress,
|
|
38223
|
+
abi: DataPortabilityServersAbi,
|
|
38224
|
+
functionName: "servers",
|
|
38225
|
+
args: [BigInt(serverId)]
|
|
38226
|
+
})
|
|
37716
38227
|
);
|
|
37717
|
-
|
|
38228
|
+
const serverInfoResults = await gasAwareMulticall(this.context.publicClient, {
|
|
38229
|
+
contracts: serverInfoCalls,
|
|
38230
|
+
allowFailure: true
|
|
38231
|
+
});
|
|
38232
|
+
return serverInfoResults.map((result, index) => {
|
|
38233
|
+
const serverId = paginatedResult.servers[index];
|
|
38234
|
+
if (result.status === "success" && result.result) {
|
|
38235
|
+
const serverInfo = result.result;
|
|
38236
|
+
return {
|
|
38237
|
+
id: BigInt(serverId),
|
|
38238
|
+
owner: serverInfo.owner,
|
|
38239
|
+
serverAddress: serverInfo.serverAddress,
|
|
38240
|
+
publicKey: serverInfo.publicKey,
|
|
38241
|
+
url: serverInfo.url,
|
|
38242
|
+
startBlock: 0n,
|
|
38243
|
+
// We don't have this info from the old method structure
|
|
38244
|
+
endBlock: 0n
|
|
38245
|
+
// 0 means still active
|
|
38246
|
+
};
|
|
38247
|
+
} else {
|
|
38248
|
+
return {
|
|
38249
|
+
id: BigInt(serverId),
|
|
38250
|
+
owner: "0x0000000000000000000000000000000000000000",
|
|
38251
|
+
serverAddress: "0x0000000000000000000000000000000000000000",
|
|
38252
|
+
publicKey: "",
|
|
38253
|
+
url: "",
|
|
38254
|
+
startBlock: 0n,
|
|
38255
|
+
endBlock: 0n
|
|
38256
|
+
};
|
|
38257
|
+
}
|
|
38258
|
+
});
|
|
37718
38259
|
} catch (error) {
|
|
37719
38260
|
throw new BlockchainError(
|
|
37720
38261
|
`Failed to get trusted servers with info: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -37725,9 +38266,28 @@ var PermissionsController = class {
|
|
|
37725
38266
|
/**
|
|
37726
38267
|
* Gets server information for multiple servers efficiently.
|
|
37727
38268
|
*
|
|
37728
|
-
* @
|
|
37729
|
-
*
|
|
38269
|
+
* @remarks
|
|
38270
|
+
* This method uses multicall to fetch information for multiple servers in a single
|
|
38271
|
+
* blockchain call, improving performance when querying many servers. Failed lookups
|
|
38272
|
+
* are returned separately for error handling.
|
|
38273
|
+
*
|
|
38274
|
+
* @param serverIds - Array of numeric server IDs to query
|
|
38275
|
+
* @returns Promise resolving to batch result containing successful lookups and failed IDs
|
|
37730
38276
|
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
38277
|
+
* @example
|
|
38278
|
+
* ```typescript
|
|
38279
|
+
* const result = await vana.permissions.getServerInfoBatch([1, 2, 3, 999]);
|
|
38280
|
+
*
|
|
38281
|
+
* // Process successful lookups
|
|
38282
|
+
* result.servers.forEach((server, id) => {
|
|
38283
|
+
* console.log(`Server ${id}: ${server.url}`);
|
|
38284
|
+
* });
|
|
38285
|
+
*
|
|
38286
|
+
* // Handle failed lookups
|
|
38287
|
+
* if (result.failed.length > 0) {
|
|
38288
|
+
* console.log(`Failed to fetch: ${result.failed.join(', ')}`);
|
|
38289
|
+
* }
|
|
38290
|
+
* ```
|
|
37731
38291
|
*/
|
|
37732
38292
|
async getServerInfoBatch(serverIds) {
|
|
37733
38293
|
if (serverIds.length === 0) {
|
|
@@ -37743,14 +38303,22 @@ var PermissionsController = class {
|
|
|
37743
38303
|
"DataPortabilityServers"
|
|
37744
38304
|
);
|
|
37745
38305
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
37746
|
-
const
|
|
37747
|
-
|
|
37748
|
-
|
|
37749
|
-
|
|
37750
|
-
|
|
37751
|
-
|
|
37752
|
-
|
|
37753
|
-
|
|
38306
|
+
const serverInfoCalls = serverIds.map(
|
|
38307
|
+
(serverId) => ({
|
|
38308
|
+
address: DataPortabilityServersAddress,
|
|
38309
|
+
abi: DataPortabilityServersAbi,
|
|
38310
|
+
functionName: "servers",
|
|
38311
|
+
args: [BigInt(serverId)]
|
|
38312
|
+
})
|
|
38313
|
+
);
|
|
38314
|
+
const serverInfoResults = await gasAwareMulticall(this.context.publicClient, {
|
|
38315
|
+
contracts: serverInfoCalls,
|
|
38316
|
+
allowFailure: true
|
|
38317
|
+
});
|
|
38318
|
+
const results = serverInfoResults.map((result, index) => {
|
|
38319
|
+
const serverId = serverIds[index];
|
|
38320
|
+
if (result.status === "success" && result.result) {
|
|
38321
|
+
const serverInfo = result.result;
|
|
37754
38322
|
const server = {
|
|
37755
38323
|
id: Number(serverInfo.id),
|
|
37756
38324
|
owner: serverInfo.owner,
|
|
@@ -37759,11 +38327,10 @@ var PermissionsController = class {
|
|
|
37759
38327
|
publicKey: serverInfo.publicKey
|
|
37760
38328
|
};
|
|
37761
38329
|
return { serverId, server, success: true };
|
|
37762
|
-
}
|
|
38330
|
+
} else {
|
|
37763
38331
|
return { serverId, server: null, success: false };
|
|
37764
38332
|
}
|
|
37765
38333
|
});
|
|
37766
|
-
const results = await Promise.all(serverInfoPromises);
|
|
37767
38334
|
const servers = /* @__PURE__ */ new Map();
|
|
37768
38335
|
const failed = [];
|
|
37769
38336
|
for (const result of results) {
|
|
@@ -37784,9 +38351,24 @@ var PermissionsController = class {
|
|
|
37784
38351
|
/**
|
|
37785
38352
|
* Checks whether a specific server is trusted by a user.
|
|
37786
38353
|
*
|
|
37787
|
-
* @
|
|
38354
|
+
* @remarks
|
|
38355
|
+
* This method queries the user's trusted server list and checks if the specified
|
|
38356
|
+
* server is present. Returns both the trust status and the index in the trust list
|
|
38357
|
+
* if trusted.
|
|
38358
|
+
*
|
|
38359
|
+
* @param serverId - Numeric server ID to check
|
|
37788
38360
|
* @param userAddress - Optional user address (defaults to current user)
|
|
37789
|
-
* @returns Promise resolving to server trust status
|
|
38361
|
+
* @returns Promise resolving to server trust status with trust index if applicable
|
|
38362
|
+
* @throws {BlockchainError} When reading from contract fails
|
|
38363
|
+
* @example
|
|
38364
|
+
* ```typescript
|
|
38365
|
+
* const status = await vana.permissions.checkServerTrustStatus(1);
|
|
38366
|
+
* if (status.isTrusted) {
|
|
38367
|
+
* console.log(`Server is trusted at index ${status.trustIndex}`);
|
|
38368
|
+
* } else {
|
|
38369
|
+
* console.log('Server is not trusted');
|
|
38370
|
+
* }
|
|
38371
|
+
* ```
|
|
37790
38372
|
*/
|
|
37791
38373
|
async checkServerTrustStatus(serverId, userAddress) {
|
|
37792
38374
|
try {
|
|
@@ -37810,6 +38392,10 @@ var PermissionsController = class {
|
|
|
37810
38392
|
/**
|
|
37811
38393
|
* Composes EIP-712 typed data for AddAndTrustServer.
|
|
37812
38394
|
*
|
|
38395
|
+
* @remarks
|
|
38396
|
+
* Creates the complete typed data structure required for EIP-712 signature generation
|
|
38397
|
+
* when adding and trusting a new server in a single transaction.
|
|
38398
|
+
*
|
|
37813
38399
|
* @param input - The add and trust server input data containing server details
|
|
37814
38400
|
* @returns Promise resolving to the typed data structure for server add and trust
|
|
37815
38401
|
*/
|
|
@@ -38058,7 +38644,11 @@ var PermissionsController = class {
|
|
|
38058
38644
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
38059
38645
|
chain: this.context.walletClient.chain || null
|
|
38060
38646
|
});
|
|
38061
|
-
return
|
|
38647
|
+
return new TransactionHandle(
|
|
38648
|
+
this.context,
|
|
38649
|
+
txHash,
|
|
38650
|
+
"registerGrantee"
|
|
38651
|
+
);
|
|
38062
38652
|
}
|
|
38063
38653
|
/**
|
|
38064
38654
|
* Registers a grantee with a signature (gasless transaction)
|
|
@@ -38085,7 +38675,15 @@ var PermissionsController = class {
|
|
|
38085
38675
|
};
|
|
38086
38676
|
const typedData = await this.buildRegisterGranteeTypedData(registerGranteeInput);
|
|
38087
38677
|
const signature = await this.signTypedData(typedData);
|
|
38088
|
-
|
|
38678
|
+
const hash = await this.submitSignedRegisterGranteeTransaction(
|
|
38679
|
+
typedData,
|
|
38680
|
+
signature
|
|
38681
|
+
);
|
|
38682
|
+
return new TransactionHandle(
|
|
38683
|
+
this.context,
|
|
38684
|
+
hash,
|
|
38685
|
+
"registerGrantee"
|
|
38686
|
+
);
|
|
38089
38687
|
}
|
|
38090
38688
|
/**
|
|
38091
38689
|
* Submits a signed register grantee transaction via relayer
|
|
@@ -38100,7 +38698,15 @@ var PermissionsController = class {
|
|
|
38100
38698
|
* ```
|
|
38101
38699
|
*/
|
|
38102
38700
|
async submitSignedRegisterGrantee(typedData, signature) {
|
|
38103
|
-
|
|
38701
|
+
const hash = await this.submitSignedRegisterGranteeTransaction(
|
|
38702
|
+
typedData,
|
|
38703
|
+
signature
|
|
38704
|
+
);
|
|
38705
|
+
return new TransactionHandle(
|
|
38706
|
+
this.context,
|
|
38707
|
+
hash,
|
|
38708
|
+
"registerGrantee"
|
|
38709
|
+
);
|
|
38104
38710
|
}
|
|
38105
38711
|
/**
|
|
38106
38712
|
* Retrieves all registered grantees from the DataPortabilityGrantees contract.
|
|
@@ -39086,7 +39692,11 @@ var PermissionsController = class {
|
|
|
39086
39692
|
chain: this.context.walletClient.chain,
|
|
39087
39693
|
account: this.context.walletClient.account || null
|
|
39088
39694
|
});
|
|
39089
|
-
return
|
|
39695
|
+
return new TransactionHandle(
|
|
39696
|
+
this.context,
|
|
39697
|
+
hash,
|
|
39698
|
+
"updateServer"
|
|
39699
|
+
);
|
|
39090
39700
|
} catch (error) {
|
|
39091
39701
|
throw new BlockchainError(
|
|
39092
39702
|
`Failed to update server: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -39267,24 +39877,30 @@ var PermissionsController = class {
|
|
|
39267
39877
|
*
|
|
39268
39878
|
* @param typedData - The EIP-712 typed data for AddPermission
|
|
39269
39879
|
* @param signature - The user's signature
|
|
39270
|
-
* @returns Promise resolving to
|
|
39880
|
+
* @returns Promise resolving to TransactionHandle with PermissionGrantResult event data
|
|
39271
39881
|
* @throws {RelayerError} When gasless transaction submission fails
|
|
39272
39882
|
* @throws {BlockchainError} When permission addition fails
|
|
39273
39883
|
* @throws {NetworkError} When network communication fails
|
|
39274
39884
|
*/
|
|
39275
39885
|
async submitSignedAddPermission(typedData, signature) {
|
|
39276
39886
|
try {
|
|
39887
|
+
let hash;
|
|
39277
39888
|
if (this.context.relayerCallbacks?.submitAddPermission) {
|
|
39278
|
-
|
|
39889
|
+
hash = await this.context.relayerCallbacks.submitAddPermission(
|
|
39279
39890
|
typedData,
|
|
39280
39891
|
signature
|
|
39281
39892
|
);
|
|
39282
39893
|
} else {
|
|
39283
|
-
|
|
39894
|
+
hash = await this.submitDirectAddPermissionTransaction(
|
|
39284
39895
|
typedData,
|
|
39285
39896
|
signature
|
|
39286
39897
|
);
|
|
39287
39898
|
}
|
|
39899
|
+
return new TransactionHandle(
|
|
39900
|
+
this.context,
|
|
39901
|
+
hash,
|
|
39902
|
+
"addServerFilesAndPermissions"
|
|
39903
|
+
);
|
|
39288
39904
|
} catch (error) {
|
|
39289
39905
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
39290
39906
|
throw error;
|
|
@@ -39338,14 +39954,31 @@ var PermissionsController = class {
|
|
|
39338
39954
|
}
|
|
39339
39955
|
/**
|
|
39340
39956
|
* Submits an already-signed add server files and permissions transaction to the blockchain.
|
|
39341
|
-
*
|
|
39957
|
+
*
|
|
39958
|
+
* @remarks
|
|
39959
|
+
* This method returns a TransactionHandle that provides immediate access to the transaction hash
|
|
39960
|
+
* while allowing lazy-loaded access to parsed event data. Use `waitForEvents()` to retrieve
|
|
39961
|
+
* the permission ID and other event details after transaction confirmation.
|
|
39342
39962
|
*
|
|
39343
39963
|
* @param typedData - The EIP-712 typed data for AddServerFilesAndPermissions
|
|
39344
39964
|
* @param signature - The user's signature
|
|
39345
|
-
* @returns
|
|
39965
|
+
* @returns TransactionHandle with immediate hash access and optional event parsing
|
|
39346
39966
|
* @throws {RelayerError} When gasless transaction submission fails
|
|
39347
39967
|
* @throws {BlockchainError} When server files and permissions addition fails
|
|
39348
39968
|
* @throws {NetworkError} When network communication fails
|
|
39969
|
+
*
|
|
39970
|
+
* @example
|
|
39971
|
+
* ```typescript
|
|
39972
|
+
* const tx = await vana.permissions.submitSignedAddServerFilesAndPermissions(
|
|
39973
|
+
* typedData,
|
|
39974
|
+
* signature
|
|
39975
|
+
* );
|
|
39976
|
+
* console.log(`Transaction submitted: ${tx.hash}`);
|
|
39977
|
+
*
|
|
39978
|
+
* // Wait for confirmation and get the permission ID
|
|
39979
|
+
* const { permissionId } = await tx.waitForEvents();
|
|
39980
|
+
* console.log(`Permission created with ID: ${permissionId}`);
|
|
39981
|
+
* ```
|
|
39349
39982
|
*/
|
|
39350
39983
|
async submitSignedAddServerFilesAndPermissions(typedData, signature) {
|
|
39351
39984
|
try {
|
|
@@ -39358,18 +39991,28 @@ var PermissionsController = class {
|
|
|
39358
39991
|
console.debug(
|
|
39359
39992
|
"\u{1F680} Using relayer for submitAddServerFilesAndPermissions"
|
|
39360
39993
|
);
|
|
39361
|
-
|
|
39994
|
+
const hash = await this.context.relayerCallbacks.submitAddServerFilesAndPermissions(
|
|
39362
39995
|
typedData,
|
|
39363
39996
|
signature
|
|
39364
39997
|
);
|
|
39998
|
+
return new TransactionHandle(
|
|
39999
|
+
this.context,
|
|
40000
|
+
hash,
|
|
40001
|
+
"addServerFilesAndPermissions"
|
|
40002
|
+
);
|
|
39365
40003
|
} else {
|
|
39366
40004
|
console.debug(
|
|
39367
40005
|
"\u{1F4DD} Using direct transaction for submitAddServerFilesAndPermissions"
|
|
39368
40006
|
);
|
|
39369
|
-
|
|
40007
|
+
const hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
|
|
39370
40008
|
typedData,
|
|
39371
40009
|
signature
|
|
39372
40010
|
);
|
|
40011
|
+
return new TransactionHandle(
|
|
40012
|
+
this.context,
|
|
40013
|
+
hash,
|
|
40014
|
+
"addServerFilesAndPermissions"
|
|
40015
|
+
);
|
|
39373
40016
|
}
|
|
39374
40017
|
} catch (error) {
|
|
39375
40018
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
@@ -39405,7 +40048,11 @@ var PermissionsController = class {
|
|
|
39405
40048
|
chain: this.context.walletClient.chain,
|
|
39406
40049
|
account: this.context.walletClient.account || null
|
|
39407
40050
|
});
|
|
39408
|
-
return
|
|
40051
|
+
return new TransactionHandle(
|
|
40052
|
+
this.context,
|
|
40053
|
+
hash,
|
|
40054
|
+
"revokePermission"
|
|
40055
|
+
);
|
|
39409
40056
|
} catch (error) {
|
|
39410
40057
|
throw new BlockchainError(
|
|
39411
40058
|
`Failed to revoke permission: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -39483,7 +40130,7 @@ var PermissionsController = class {
|
|
|
39483
40130
|
};
|
|
39484
40131
|
|
|
39485
40132
|
// src/controllers/data.ts
|
|
39486
|
-
import { getContract as getContract2
|
|
40133
|
+
import { getContract as getContract2 } from "viem";
|
|
39487
40134
|
|
|
39488
40135
|
// src/utils/blockchain/registry.ts
|
|
39489
40136
|
import { getContract } from "viem";
|
|
@@ -39507,13 +40154,13 @@ async function fetchSchemaFromChain(context, schemaId) {
|
|
|
39507
40154
|
throw new Error(`Schema with ID ${schemaId} not found`);
|
|
39508
40155
|
}
|
|
39509
40156
|
const schemaObj = schemaData;
|
|
39510
|
-
if (!schemaObj.name || !schemaObj.
|
|
40157
|
+
if (!schemaObj.name || !schemaObj.dialect || !schemaObj.definitionUrl) {
|
|
39511
40158
|
throw new Error("Incomplete schema data");
|
|
39512
40159
|
}
|
|
39513
40160
|
return {
|
|
39514
40161
|
id: schemaId,
|
|
39515
40162
|
name: schemaObj.name,
|
|
39516
|
-
|
|
40163
|
+
dialect: schemaObj.dialect,
|
|
39517
40164
|
definitionUrl: schemaObj.definitionUrl
|
|
39518
40165
|
};
|
|
39519
40166
|
}
|
|
@@ -39960,8 +40607,8 @@ var DataController = class {
|
|
|
39960
40607
|
*/
|
|
39961
40608
|
async getUserFiles(params) {
|
|
39962
40609
|
const { owner, subgraphUrl } = params;
|
|
39963
|
-
const
|
|
39964
|
-
if (!
|
|
40610
|
+
const endpoint = subgraphUrl || this.context.subgraphUrl;
|
|
40611
|
+
if (!endpoint) {
|
|
39965
40612
|
throw new Error(
|
|
39966
40613
|
"subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
|
|
39967
40614
|
);
|
|
@@ -39985,7 +40632,7 @@ var DataController = class {
|
|
|
39985
40632
|
}
|
|
39986
40633
|
}
|
|
39987
40634
|
`;
|
|
39988
|
-
const response = await fetch(
|
|
40635
|
+
const response = await fetch(endpoint, {
|
|
39989
40636
|
method: "POST",
|
|
39990
40637
|
headers: {
|
|
39991
40638
|
"Content-Type": "application/json"
|
|
@@ -40043,28 +40690,45 @@ var DataController = class {
|
|
|
40043
40690
|
}
|
|
40044
40691
|
}
|
|
40045
40692
|
/**
|
|
40046
|
-
* Retrieves a list of permissions granted by a user
|
|
40693
|
+
* Retrieves a list of permissions granted by a user.
|
|
40047
40694
|
*
|
|
40048
|
-
* This method
|
|
40049
|
-
*
|
|
40050
|
-
*
|
|
40051
|
-
*
|
|
40052
|
-
* 3. No need for additional contract calls as all data comes from subgraph
|
|
40695
|
+
* This method supports automatic fallback between subgraph and RPC modes:
|
|
40696
|
+
* - If subgraph URL is available, tries subgraph query first
|
|
40697
|
+
* - Falls back to direct contract queries via RPC if subgraph fails
|
|
40698
|
+
* - RPC mode uses gasAwareMulticall for efficient batch queries
|
|
40053
40699
|
*
|
|
40054
40700
|
* @param params - Object containing the user address and optional subgraph URL
|
|
40055
40701
|
* @param params.user - The wallet address of the user to query permissions for
|
|
40056
40702
|
* @param params.subgraphUrl - Optional subgraph URL to override the default
|
|
40057
40703
|
* @returns Promise resolving to an array of permission objects
|
|
40058
|
-
* @throws Error if subgraph
|
|
40704
|
+
* @throws Error if both subgraph and RPC queries fail
|
|
40059
40705
|
*/
|
|
40060
40706
|
async getUserPermissions(params) {
|
|
40061
40707
|
const { user, subgraphUrl } = params;
|
|
40062
|
-
const
|
|
40063
|
-
if (
|
|
40064
|
-
|
|
40065
|
-
|
|
40066
|
-
|
|
40708
|
+
const endpoint = subgraphUrl || this.context.subgraphUrl;
|
|
40709
|
+
if (endpoint) {
|
|
40710
|
+
try {
|
|
40711
|
+
const permissions = await this._getUserPermissionsViaSubgraph({
|
|
40712
|
+
user,
|
|
40713
|
+
subgraphUrl: endpoint
|
|
40714
|
+
});
|
|
40715
|
+
return permissions;
|
|
40716
|
+
} catch (error) {
|
|
40717
|
+
console.warn("Subgraph query failed, falling back to RPC:", error);
|
|
40718
|
+
}
|
|
40067
40719
|
}
|
|
40720
|
+
return await this._getUserPermissionsViaRpc({ user });
|
|
40721
|
+
}
|
|
40722
|
+
/**
|
|
40723
|
+
* Internal method: Query user permissions via subgraph
|
|
40724
|
+
*
|
|
40725
|
+
* @param params - Query parameters object
|
|
40726
|
+
* @param params.user - The user address to query permissions for
|
|
40727
|
+
* @param params.subgraphUrl - The subgraph URL endpoint to query
|
|
40728
|
+
* @returns Promise resolving to an array of permission objects
|
|
40729
|
+
*/
|
|
40730
|
+
async _getUserPermissionsViaSubgraph(params) {
|
|
40731
|
+
const { user, subgraphUrl } = params;
|
|
40068
40732
|
try {
|
|
40069
40733
|
const query = `
|
|
40070
40734
|
query GetUserPermissions($userId: ID!) {
|
|
@@ -40085,7 +40749,7 @@ var DataController = class {
|
|
|
40085
40749
|
}
|
|
40086
40750
|
}
|
|
40087
40751
|
`;
|
|
40088
|
-
const response = await fetch(
|
|
40752
|
+
const response = await fetch(subgraphUrl, {
|
|
40089
40753
|
method: "POST",
|
|
40090
40754
|
headers: {
|
|
40091
40755
|
"Content-Type": "application/json"
|
|
@@ -40105,15 +40769,14 @@ var DataController = class {
|
|
|
40105
40769
|
const result = await response.json();
|
|
40106
40770
|
if (result.errors) {
|
|
40107
40771
|
throw new Error(
|
|
40108
|
-
`Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
40772
|
+
`Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
40109
40773
|
);
|
|
40110
40774
|
}
|
|
40111
40775
|
const userData = result.data?.user;
|
|
40112
40776
|
if (!userData || !userData.permissions?.length) {
|
|
40113
|
-
console.warn("No permissions found for user:", user);
|
|
40114
40777
|
return [];
|
|
40115
40778
|
}
|
|
40116
|
-
|
|
40779
|
+
return userData.permissions.map((permission) => ({
|
|
40117
40780
|
id: permission.id,
|
|
40118
40781
|
grant: permission.grant,
|
|
40119
40782
|
nonce: BigInt(permission.nonce),
|
|
@@ -40123,131 +40786,158 @@ var DataController = class {
|
|
|
40123
40786
|
transactionHash: permission.transactionHash,
|
|
40124
40787
|
user: permission.user.id
|
|
40125
40788
|
})).sort((a, b) => Number(b.addedAtTimestamp - a.addedAtTimestamp));
|
|
40789
|
+
} catch (error) {
|
|
40790
|
+
console.error("Failed to query user permissions from subgraph:", error);
|
|
40791
|
+
throw error;
|
|
40792
|
+
}
|
|
40793
|
+
}
|
|
40794
|
+
/**
|
|
40795
|
+
* Internal method: Query user permissions via direct RPC
|
|
40796
|
+
*
|
|
40797
|
+
* @param params - Query parameters object
|
|
40798
|
+
* @param params.user - The user address to query permissions for
|
|
40799
|
+
* @returns Promise resolving to an array of permission objects
|
|
40800
|
+
*/
|
|
40801
|
+
async _getUserPermissionsViaRpc(params) {
|
|
40802
|
+
const { user } = params;
|
|
40803
|
+
try {
|
|
40804
|
+
const chainId = this.context.walletClient.chain?.id;
|
|
40805
|
+
if (!chainId) {
|
|
40806
|
+
throw new Error("Chain ID not available");
|
|
40807
|
+
}
|
|
40808
|
+
const permissionsAddress = getContractAddress(
|
|
40809
|
+
chainId,
|
|
40810
|
+
"DataPortabilityPermissions"
|
|
40811
|
+
);
|
|
40812
|
+
const permissionsAbi = getAbi("DataPortabilityPermissions");
|
|
40813
|
+
const totalCount = await this.context.publicClient.readContract({
|
|
40814
|
+
address: permissionsAddress,
|
|
40815
|
+
abi: permissionsAbi,
|
|
40816
|
+
functionName: "userPermissionIdsLength",
|
|
40817
|
+
args: [user]
|
|
40818
|
+
});
|
|
40819
|
+
const total = Number(totalCount);
|
|
40820
|
+
if (total === 0) {
|
|
40821
|
+
return [];
|
|
40822
|
+
}
|
|
40823
|
+
const permissionIdCalls = [];
|
|
40824
|
+
for (let i = 0; i < total; i++) {
|
|
40825
|
+
permissionIdCalls.push({
|
|
40826
|
+
address: permissionsAddress,
|
|
40827
|
+
abi: permissionsAbi,
|
|
40828
|
+
functionName: "userPermissionIdsAt",
|
|
40829
|
+
args: [user, BigInt(i)]
|
|
40830
|
+
});
|
|
40831
|
+
}
|
|
40832
|
+
const permissionIdResults = await gasAwareMulticall(this.context.publicClient, {
|
|
40833
|
+
contracts: permissionIdCalls
|
|
40834
|
+
});
|
|
40835
|
+
const permissionIds = permissionIdResults.map((result) => result).filter((id) => id && id > 0n);
|
|
40836
|
+
const permissionInfoCalls = permissionIds.map(
|
|
40837
|
+
(permissionId) => ({
|
|
40838
|
+
address: permissionsAddress,
|
|
40839
|
+
abi: permissionsAbi,
|
|
40840
|
+
functionName: "permissions",
|
|
40841
|
+
args: [permissionId]
|
|
40842
|
+
})
|
|
40843
|
+
);
|
|
40844
|
+
const permissionInfoResults = await gasAwareMulticall(this.context.publicClient, {
|
|
40845
|
+
contracts: permissionInfoCalls,
|
|
40846
|
+
allowFailure: true
|
|
40847
|
+
});
|
|
40848
|
+
const permissions = permissionInfoResults.map((result, index) => {
|
|
40849
|
+
const permissionId = permissionIds[index];
|
|
40850
|
+
if (result.status === "success" && result.result) {
|
|
40851
|
+
const permissionInfo = result.result;
|
|
40852
|
+
return {
|
|
40853
|
+
id: permissionId.toString(),
|
|
40854
|
+
grant: permissionInfo.grant,
|
|
40855
|
+
nonce: permissionInfo.nonce,
|
|
40856
|
+
signature: "",
|
|
40857
|
+
// Not available from RPC, will be empty
|
|
40858
|
+
addedAtBlock: permissionInfo.startBlock,
|
|
40859
|
+
addedAtTimestamp: BigInt(0),
|
|
40860
|
+
// Not available from RPC
|
|
40861
|
+
transactionHash: "0x0000000000000000000000000000000000000000",
|
|
40862
|
+
// Not available from RPC
|
|
40863
|
+
user
|
|
40864
|
+
};
|
|
40865
|
+
} else {
|
|
40866
|
+
return {
|
|
40867
|
+
id: permissionId.toString(),
|
|
40868
|
+
grant: "",
|
|
40869
|
+
nonce: BigInt(0),
|
|
40870
|
+
signature: "",
|
|
40871
|
+
addedAtBlock: BigInt(0),
|
|
40872
|
+
addedAtTimestamp: BigInt(0),
|
|
40873
|
+
transactionHash: "0x0000000000000000000000000000000000000000",
|
|
40874
|
+
user
|
|
40875
|
+
};
|
|
40876
|
+
}
|
|
40877
|
+
}).filter((permission) => permission.grant !== "");
|
|
40126
40878
|
return permissions;
|
|
40127
40879
|
} catch (error) {
|
|
40128
|
-
console.error("Failed to fetch user permissions from subgraph:", error);
|
|
40129
40880
|
throw new Error(
|
|
40130
|
-
`
|
|
40881
|
+
`RPC query failed: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
40131
40882
|
);
|
|
40132
40883
|
}
|
|
40133
40884
|
}
|
|
40134
40885
|
/**
|
|
40135
|
-
* Retrieves a list of trusted servers for a user
|
|
40886
|
+
* Retrieves a list of trusted servers for a user.
|
|
40136
40887
|
*
|
|
40137
|
-
* This method
|
|
40138
|
-
*
|
|
40888
|
+
* This method supports automatic fallback between subgraph and RPC modes:
|
|
40889
|
+
* - If subgraph URL is available, tries subgraph query first for fast results
|
|
40890
|
+
* - Falls back to direct contract queries via RPC if subgraph fails
|
|
40891
|
+
* - RPC mode uses gasAwareMulticall for efficient batch queries
|
|
40139
40892
|
*
|
|
40140
|
-
*
|
|
40141
|
-
* -
|
|
40142
|
-
*
|
|
40143
|
-
* -
|
|
40144
|
-
*
|
|
40145
|
-
* @
|
|
40146
|
-
* @
|
|
40147
|
-
* @throws Error if query fails in both modes (when using 'auto')
|
|
40893
|
+
* @param params - Query parameters including user address and optional pagination
|
|
40894
|
+
* @param params.user - The wallet address of the user to query trusted servers for
|
|
40895
|
+
* @param params.subgraphUrl - Optional subgraph URL to override the default
|
|
40896
|
+
* @param params.limit - Maximum number of results to return (default: 50)
|
|
40897
|
+
* @param params.offset - Number of results to skip for pagination (default: 0)
|
|
40898
|
+
* @returns Promise resolving to an array of trusted server objects
|
|
40899
|
+
* @throws Error if both subgraph and RPC queries fail
|
|
40148
40900
|
* @example
|
|
40149
40901
|
* ```typescript
|
|
40150
|
-
* //
|
|
40151
|
-
* const
|
|
40152
|
-
* user: '0x...'
|
|
40153
|
-
* mode: 'subgraph',
|
|
40154
|
-
* subgraphUrl: 'https://...'
|
|
40902
|
+
* // Basic usage with automatic fallback
|
|
40903
|
+
* const servers = await vana.data.getUserTrustedServers({
|
|
40904
|
+
* user: '0x...'
|
|
40155
40905
|
* });
|
|
40156
40906
|
*
|
|
40157
|
-
* //
|
|
40158
|
-
* const
|
|
40907
|
+
* // With pagination
|
|
40908
|
+
* const servers = await vana.data.getUserTrustedServers({
|
|
40159
40909
|
* user: '0x...',
|
|
40160
|
-
*
|
|
40161
|
-
*
|
|
40910
|
+
* limit: 10,
|
|
40911
|
+
* offset: 20
|
|
40162
40912
|
* });
|
|
40163
40913
|
*
|
|
40164
|
-
* //
|
|
40165
|
-
* const
|
|
40914
|
+
* // With custom subgraph URL
|
|
40915
|
+
* const servers = await vana.data.getUserTrustedServers({
|
|
40166
40916
|
* user: '0x...',
|
|
40167
|
-
*
|
|
40917
|
+
* subgraphUrl: 'https://custom-subgraph.com/graphql'
|
|
40168
40918
|
* });
|
|
40169
40919
|
* ```
|
|
40170
40920
|
*/
|
|
40171
40921
|
async getUserTrustedServers(params) {
|
|
40172
|
-
const { user,
|
|
40173
|
-
const
|
|
40174
|
-
|
|
40175
|
-
let tryRpc = false;
|
|
40176
|
-
switch (mode) {
|
|
40177
|
-
case "subgraph":
|
|
40178
|
-
trySubgraph = true;
|
|
40179
|
-
break;
|
|
40180
|
-
case "rpc":
|
|
40181
|
-
tryRpc = true;
|
|
40182
|
-
break;
|
|
40183
|
-
case "auto":
|
|
40184
|
-
trySubgraph = true;
|
|
40185
|
-
tryRpc = true;
|
|
40186
|
-
break;
|
|
40187
|
-
}
|
|
40188
|
-
if (trySubgraph) {
|
|
40189
|
-
const subgraphUrl = params.subgraphUrl || this.context.subgraphUrl;
|
|
40190
|
-
if (!subgraphUrl) {
|
|
40191
|
-
if (mode === "subgraph") {
|
|
40192
|
-
throw new Error(
|
|
40193
|
-
"subgraphUrl is required for subgraph mode. Please provide a valid subgraph endpoint or configure it in Vana constructor."
|
|
40194
|
-
);
|
|
40195
|
-
}
|
|
40196
|
-
warnings.push(
|
|
40197
|
-
"Subgraph mode not available for trusted servers - using direct contract calls"
|
|
40198
|
-
);
|
|
40199
|
-
} else {
|
|
40200
|
-
try {
|
|
40201
|
-
const servers = await this._getUserTrustedServersViaSubgraph({
|
|
40202
|
-
user,
|
|
40203
|
-
subgraphUrl
|
|
40204
|
-
});
|
|
40205
|
-
const paginatedServers = limit ? servers.slice(offset, offset + limit) : servers;
|
|
40206
|
-
return {
|
|
40207
|
-
servers: paginatedServers,
|
|
40208
|
-
usedMode: "subgraph",
|
|
40209
|
-
total: servers.length,
|
|
40210
|
-
hasMore: limit ? offset + limit < servers.length : false,
|
|
40211
|
-
warnings: warnings.length > 0 ? warnings : void 0
|
|
40212
|
-
};
|
|
40213
|
-
} catch (error) {
|
|
40214
|
-
if (mode === "subgraph") {
|
|
40215
|
-
throw error;
|
|
40216
|
-
}
|
|
40217
|
-
warnings.push(
|
|
40218
|
-
`Subgraph query failed: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
40219
|
-
);
|
|
40220
|
-
console.warn(
|
|
40221
|
-
"Subgraph query failed, falling back to RPC mode:",
|
|
40222
|
-
error
|
|
40223
|
-
);
|
|
40224
|
-
}
|
|
40225
|
-
}
|
|
40226
|
-
}
|
|
40227
|
-
if (tryRpc) {
|
|
40922
|
+
const { user, limit = 50, offset = 0 } = params;
|
|
40923
|
+
const subgraphUrl = params.subgraphUrl || this.context.subgraphUrl;
|
|
40924
|
+
if (subgraphUrl) {
|
|
40228
40925
|
try {
|
|
40229
|
-
const
|
|
40926
|
+
const servers = await this._getUserTrustedServersViaSubgraph({
|
|
40230
40927
|
user,
|
|
40231
|
-
|
|
40232
|
-
offset
|
|
40928
|
+
subgraphUrl
|
|
40233
40929
|
});
|
|
40234
|
-
return
|
|
40235
|
-
servers: rpcResult.servers,
|
|
40236
|
-
usedMode: "rpc",
|
|
40237
|
-
total: rpcResult.total,
|
|
40238
|
-
hasMore: rpcResult.hasMore,
|
|
40239
|
-
warnings: warnings.length > 0 ? warnings : void 0
|
|
40240
|
-
};
|
|
40930
|
+
return limit ? servers.slice(offset, offset + limit) : servers;
|
|
40241
40931
|
} catch (error) {
|
|
40242
|
-
|
|
40243
|
-
throw error;
|
|
40244
|
-
}
|
|
40245
|
-
throw new Error(
|
|
40246
|
-
`Both query methods failed. Subgraph: ${warnings[0] || "Unknown error"}. RPC: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
40247
|
-
);
|
|
40932
|
+
console.warn("Subgraph query failed, falling back to RPC:", error);
|
|
40248
40933
|
}
|
|
40249
40934
|
}
|
|
40250
|
-
|
|
40935
|
+
const rpcResult = await this._getUserTrustedServersViaRpc({
|
|
40936
|
+
user,
|
|
40937
|
+
limit,
|
|
40938
|
+
offset
|
|
40939
|
+
});
|
|
40940
|
+
return rpcResult.servers;
|
|
40251
40941
|
}
|
|
40252
40942
|
/**
|
|
40253
40943
|
* Internal method: Query trusted servers via subgraph
|
|
@@ -40363,35 +41053,44 @@ var DataController = class {
|
|
|
40363
41053
|
};
|
|
40364
41054
|
}
|
|
40365
41055
|
const endIndex = Math.min(offset + limit, total);
|
|
40366
|
-
const
|
|
41056
|
+
const serverIdCalls = [];
|
|
40367
41057
|
for (let i = offset; i < endIndex; i++) {
|
|
40368
|
-
|
|
41058
|
+
serverIdCalls.push({
|
|
40369
41059
|
address: DataPortabilityServersAddress,
|
|
40370
41060
|
abi: DataPortabilityServersAbi,
|
|
40371
41061
|
functionName: "userServerIdsAt",
|
|
40372
41062
|
args: [user, BigInt(i)]
|
|
40373
41063
|
});
|
|
40374
|
-
serverIdPromises.push(promise);
|
|
40375
41064
|
}
|
|
40376
|
-
const
|
|
40377
|
-
|
|
40378
|
-
|
|
40379
|
-
|
|
40380
|
-
|
|
40381
|
-
|
|
40382
|
-
|
|
40383
|
-
|
|
40384
|
-
|
|
41065
|
+
const serverIdResults = await gasAwareMulticall(this.context.publicClient, {
|
|
41066
|
+
contracts: serverIdCalls
|
|
41067
|
+
});
|
|
41068
|
+
const serverIds = serverIdResults.map((result) => result).filter((id) => id && id > 0n);
|
|
41069
|
+
const serverInfoCalls = serverIds.map(
|
|
41070
|
+
(serverId) => ({
|
|
41071
|
+
address: DataPortabilityServersAddress,
|
|
41072
|
+
abi: DataPortabilityServersAbi,
|
|
41073
|
+
functionName: "servers",
|
|
41074
|
+
args: [serverId]
|
|
41075
|
+
})
|
|
41076
|
+
);
|
|
41077
|
+
const serverInfoResults = await gasAwareMulticall(this.context.publicClient, {
|
|
41078
|
+
contracts: serverInfoCalls,
|
|
41079
|
+
allowFailure: true
|
|
41080
|
+
});
|
|
41081
|
+
const servers = serverInfoResults.map((result, index) => {
|
|
41082
|
+
const serverId = serverIds[index];
|
|
41083
|
+
if (result.status === "success" && result.result) {
|
|
41084
|
+
const serverInfo = result.result;
|
|
40385
41085
|
return {
|
|
40386
41086
|
id: `${user.toLowerCase()}-${serverId.toString()}`,
|
|
40387
41087
|
serverAddress: serverInfo.serverAddress,
|
|
40388
41088
|
serverUrl: serverInfo.url,
|
|
40389
41089
|
trustedAt: BigInt(Date.now()),
|
|
40390
|
-
// RPC mode doesn't have timestamp, use current time
|
|
40391
41090
|
user,
|
|
40392
41091
|
trustIndex: offset + index
|
|
40393
41092
|
};
|
|
40394
|
-
}
|
|
41093
|
+
} else {
|
|
40395
41094
|
return {
|
|
40396
41095
|
id: `${user.toLowerCase()}-${serverId.toString()}`,
|
|
40397
41096
|
serverAddress: "0x0000000000000000000000000000000000000000",
|
|
@@ -40402,7 +41101,6 @@ var DataController = class {
|
|
|
40402
41101
|
};
|
|
40403
41102
|
}
|
|
40404
41103
|
});
|
|
40405
|
-
const servers = await Promise.all(serverInfoPromises);
|
|
40406
41104
|
return {
|
|
40407
41105
|
servers,
|
|
40408
41106
|
total,
|
|
@@ -40529,12 +41227,25 @@ var DataController = class {
|
|
|
40529
41227
|
/**
|
|
40530
41228
|
* Registers a file URL directly on the blockchain with a schema ID.
|
|
40531
41229
|
*
|
|
40532
|
-
* @
|
|
41230
|
+
* @remarks
|
|
41231
|
+
* This method registers an existing file URL on the DataRegistry contract
|
|
41232
|
+
* with a schema ID, without uploading any data. Useful when you have already
|
|
41233
|
+
* uploaded content to storage and just need to register it on-chain.
|
|
41234
|
+
*
|
|
41235
|
+
* @param url - The URL of the file to register (IPFS or HTTP/HTTPS)
|
|
40533
41236
|
* @param schemaId - The schema ID to associate with the file
|
|
40534
41237
|
* @returns Promise resolving to the file ID and transaction hash
|
|
40535
|
-
*
|
|
40536
|
-
*
|
|
40537
|
-
*
|
|
41238
|
+
* @throws {Error} When chain ID is not available - "Chain ID not available"
|
|
41239
|
+
* @throws {Error} When wallet address is unavailable - "No addresses available"
|
|
41240
|
+
* @throws {Error} When transaction fails - "Failed to register file with schema"
|
|
41241
|
+
* @example
|
|
41242
|
+
* ```typescript
|
|
41243
|
+
* const { fileId, transactionHash } = await vana.data.registerFileWithSchema(
|
|
41244
|
+
* "ipfs://QmXxx...",
|
|
41245
|
+
* 1
|
|
41246
|
+
* );
|
|
41247
|
+
* console.log(`File ${fileId} registered with schema in tx ${transactionHash}`);
|
|
41248
|
+
* ```
|
|
40538
41249
|
*/
|
|
40539
41250
|
async registerFileWithSchema(url, schemaId) {
|
|
40540
41251
|
try {
|
|
@@ -40553,30 +41264,14 @@ var DataController = class {
|
|
|
40553
41264
|
account: this.context.walletClient.account || userAddress,
|
|
40554
41265
|
chain: this.context.walletClient.chain || null
|
|
40555
41266
|
});
|
|
40556
|
-
const
|
|
40557
|
-
|
|
40558
|
-
|
|
40559
|
-
|
|
40560
|
-
}
|
|
41267
|
+
const txHandle = new TransactionHandle(
|
|
41268
|
+
this.context,
|
|
41269
|
+
txHash,
|
|
41270
|
+
"addFileWithSchema"
|
|
40561
41271
|
);
|
|
40562
|
-
|
|
40563
|
-
for (const log of receipt.logs) {
|
|
40564
|
-
try {
|
|
40565
|
-
const decoded = decodeEventLog({
|
|
40566
|
-
abi: dataRegistryAbi,
|
|
40567
|
-
data: log.data,
|
|
40568
|
-
topics: log.topics
|
|
40569
|
-
});
|
|
40570
|
-
if (decoded.eventName === "FileAdded") {
|
|
40571
|
-
fileId = Number(decoded.args.fileId);
|
|
40572
|
-
break;
|
|
40573
|
-
}
|
|
40574
|
-
} catch {
|
|
40575
|
-
continue;
|
|
40576
|
-
}
|
|
40577
|
-
}
|
|
41272
|
+
const result = await txHandle.waitForEvents();
|
|
40578
41273
|
return {
|
|
40579
|
-
fileId,
|
|
41274
|
+
fileId: Number(result.fileId),
|
|
40580
41275
|
transactionHash: txHash
|
|
40581
41276
|
};
|
|
40582
41277
|
} catch (error) {
|
|
@@ -40631,31 +41326,14 @@ var DataController = class {
|
|
|
40631
41326
|
account: this.context.walletClient.account || ownerAddress,
|
|
40632
41327
|
chain: this.context.walletClient.chain || null
|
|
40633
41328
|
});
|
|
40634
|
-
const
|
|
40635
|
-
|
|
40636
|
-
|
|
40637
|
-
|
|
40638
|
-
// 30 seconds timeout
|
|
40639
|
-
}
|
|
41329
|
+
const txHandle = new TransactionHandle(
|
|
41330
|
+
this.context,
|
|
41331
|
+
txHash,
|
|
41332
|
+
"addFileWithPermissions"
|
|
40640
41333
|
);
|
|
40641
|
-
|
|
40642
|
-
for (const log of receipt.logs) {
|
|
40643
|
-
try {
|
|
40644
|
-
const decoded = decodeEventLog({
|
|
40645
|
-
abi: dataRegistryAbi,
|
|
40646
|
-
data: log.data,
|
|
40647
|
-
topics: log.topics
|
|
40648
|
-
});
|
|
40649
|
-
if (decoded.eventName === "FileAdded") {
|
|
40650
|
-
fileId = Number(decoded.args.fileId);
|
|
40651
|
-
break;
|
|
40652
|
-
}
|
|
40653
|
-
} catch {
|
|
40654
|
-
continue;
|
|
40655
|
-
}
|
|
40656
|
-
}
|
|
41334
|
+
const result = await txHandle.waitForEvents();
|
|
40657
41335
|
return {
|
|
40658
|
-
fileId,
|
|
41336
|
+
fileId: Number(result.fileId),
|
|
40659
41337
|
transactionHash: txHash
|
|
40660
41338
|
};
|
|
40661
41339
|
} catch (error) {
|
|
@@ -40695,31 +41373,14 @@ var DataController = class {
|
|
|
40695
41373
|
account: this.context.walletClient.account || ownerAddress,
|
|
40696
41374
|
chain: this.context.walletClient.chain || null
|
|
40697
41375
|
});
|
|
40698
|
-
const
|
|
40699
|
-
|
|
40700
|
-
|
|
40701
|
-
|
|
40702
|
-
// 30 seconds timeout
|
|
40703
|
-
}
|
|
41376
|
+
const txHandle = new TransactionHandle(
|
|
41377
|
+
this.context,
|
|
41378
|
+
txHash,
|
|
41379
|
+
"addFileWithPermissionsAndSchema"
|
|
40704
41380
|
);
|
|
40705
|
-
|
|
40706
|
-
for (const log of receipt.logs) {
|
|
40707
|
-
try {
|
|
40708
|
-
const decoded = decodeEventLog({
|
|
40709
|
-
abi: dataRegistryAbi,
|
|
40710
|
-
data: log.data,
|
|
40711
|
-
topics: log.topics
|
|
40712
|
-
});
|
|
40713
|
-
if (decoded.eventName === "FileAdded") {
|
|
40714
|
-
fileId = Number(decoded.args.fileId);
|
|
40715
|
-
break;
|
|
40716
|
-
}
|
|
40717
|
-
} catch {
|
|
40718
|
-
continue;
|
|
40719
|
-
}
|
|
40720
|
-
}
|
|
41381
|
+
const result = await txHandle.waitForEvents();
|
|
40721
41382
|
return {
|
|
40722
|
-
fileId,
|
|
41383
|
+
fileId: Number(result.fileId),
|
|
40723
41384
|
transactionHash: txHash
|
|
40724
41385
|
};
|
|
40725
41386
|
} catch (error) {
|
|
@@ -40732,8 +41393,30 @@ var DataController = class {
|
|
|
40732
41393
|
/**
|
|
40733
41394
|
* Adds a new refiner to the DataRefinerRegistry.
|
|
40734
41395
|
*
|
|
40735
|
-
* @
|
|
41396
|
+
* @remarks
|
|
41397
|
+
* Refiners are data processing templates that define how raw data should be
|
|
41398
|
+
* transformed into structured formats. Each refiner is associated with a DLP
|
|
41399
|
+
* (Data Liquidity Pool), has a specific schema for output, and includes
|
|
41400
|
+
* instructions for the refinement process.
|
|
41401
|
+
*
|
|
41402
|
+
* @param params - Refiner configuration parameters
|
|
41403
|
+
* @param params.dlpId - The Data Liquidity Pool ID this refiner belongs to
|
|
41404
|
+
* @param params.name - Human-readable name for the refiner
|
|
41405
|
+
* @param params.schemaId - Schema ID that defines the output format
|
|
41406
|
+
* @param params.refinementInstructionUrl - URL containing processing instructions
|
|
40736
41407
|
* @returns Promise resolving to the new refiner ID and transaction hash
|
|
41408
|
+
* @throws {Error} When chain ID is not available - "Chain ID not available"
|
|
41409
|
+
* @throws {Error} When transaction fails - "Failed to add refiner: {error}"
|
|
41410
|
+
* @example
|
|
41411
|
+
* ```typescript
|
|
41412
|
+
* const result = await vana.data.addRefiner({
|
|
41413
|
+
* dlpId: 1,
|
|
41414
|
+
* name: "Social Media Sentiment Analyzer",
|
|
41415
|
+
* schemaId: 42,
|
|
41416
|
+
* refinementInstructionUrl: "ipfs://QmXxx..."
|
|
41417
|
+
* });
|
|
41418
|
+
* console.log(`Created refiner ${result.refinerId} in tx ${result.transactionHash}`);
|
|
41419
|
+
* ```
|
|
40737
41420
|
*/
|
|
40738
41421
|
async addRefiner(params) {
|
|
40739
41422
|
try {
|
|
@@ -40759,30 +41442,14 @@ var DataController = class {
|
|
|
40759
41442
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
40760
41443
|
chain: this.context.walletClient.chain || null
|
|
40761
41444
|
});
|
|
40762
|
-
const
|
|
40763
|
-
|
|
40764
|
-
|
|
40765
|
-
|
|
40766
|
-
}
|
|
41445
|
+
const txHandle = new TransactionHandle(
|
|
41446
|
+
this.context,
|
|
41447
|
+
txHash,
|
|
41448
|
+
"addRefiner"
|
|
40767
41449
|
);
|
|
40768
|
-
|
|
40769
|
-
for (const log of receipt.logs) {
|
|
40770
|
-
try {
|
|
40771
|
-
const decoded = decodeEventLog({
|
|
40772
|
-
abi: dataRefinerRegistryAbi,
|
|
40773
|
-
data: log.data,
|
|
40774
|
-
topics: log.topics
|
|
40775
|
-
});
|
|
40776
|
-
if (decoded.eventName === "RefinerAdded") {
|
|
40777
|
-
refinerId = Number(decoded.args.refinerId);
|
|
40778
|
-
break;
|
|
40779
|
-
}
|
|
40780
|
-
} catch {
|
|
40781
|
-
continue;
|
|
40782
|
-
}
|
|
40783
|
-
}
|
|
41450
|
+
const result = await txHandle.waitForEvents();
|
|
40784
41451
|
return {
|
|
40785
|
-
refinerId,
|
|
41452
|
+
refinerId: Number(result.refinerId),
|
|
40786
41453
|
transactionHash: txHash
|
|
40787
41454
|
};
|
|
40788
41455
|
} catch (error) {
|
|
@@ -40795,8 +41462,25 @@ var DataController = class {
|
|
|
40795
41462
|
/**
|
|
40796
41463
|
* Retrieves a refiner by its ID.
|
|
40797
41464
|
*
|
|
40798
|
-
* @
|
|
40799
|
-
*
|
|
41465
|
+
* @remarks
|
|
41466
|
+
* Queries the DataRefinerRegistry contract to get complete information about
|
|
41467
|
+
* a specific refiner including its DLP association, schema, and instructions.
|
|
41468
|
+
*
|
|
41469
|
+
* @param refinerId - The numeric refiner ID to retrieve
|
|
41470
|
+
* @returns Promise resolving to the refiner information object
|
|
41471
|
+
* @throws {Error} When chain ID is not available - "Chain ID not available"
|
|
41472
|
+
* @throws {Error} When refiner doesn't exist - "Refiner with ID {refinerId} does not exist"
|
|
41473
|
+
* @throws {Error} When contract read fails - "Failed to fetch refiner: {error}"
|
|
41474
|
+
* @example
|
|
41475
|
+
* ```typescript
|
|
41476
|
+
* const refiner = await vana.data.getRefiner(1);
|
|
41477
|
+
* console.log({
|
|
41478
|
+
* name: refiner.name,
|
|
41479
|
+
* dlp: refiner.dlpId,
|
|
41480
|
+
* schema: refiner.schemaId,
|
|
41481
|
+
* instructions: refiner.refinementInstructionUrl
|
|
41482
|
+
* });
|
|
41483
|
+
* ```
|
|
40800
41484
|
*/
|
|
40801
41485
|
async getRefiner(refinerId) {
|
|
40802
41486
|
try {
|
|
@@ -40838,8 +41522,21 @@ var DataController = class {
|
|
|
40838
41522
|
/**
|
|
40839
41523
|
* Validates if a schema ID exists in the registry.
|
|
40840
41524
|
*
|
|
40841
|
-
* @
|
|
40842
|
-
*
|
|
41525
|
+
* @remarks
|
|
41526
|
+
* Checks the DataRefinerRegistry contract to determine if a given schema ID
|
|
41527
|
+
* has been registered and is available for use.
|
|
41528
|
+
*
|
|
41529
|
+
* @param schemaId - The numeric schema ID to validate
|
|
41530
|
+
* @returns Promise resolving to true if schema exists, false otherwise
|
|
41531
|
+
* @example
|
|
41532
|
+
* ```typescript
|
|
41533
|
+
* const isValid = await vana.data.isValidSchemaId(42);
|
|
41534
|
+
* if (isValid) {
|
|
41535
|
+
* console.log('Schema 42 is available for use');
|
|
41536
|
+
* } else {
|
|
41537
|
+
* console.log('Schema 42 does not exist');
|
|
41538
|
+
* }
|
|
41539
|
+
* ```
|
|
40843
41540
|
*/
|
|
40844
41541
|
async isValidSchemaId(schemaId) {
|
|
40845
41542
|
try {
|
|
@@ -40869,7 +41566,16 @@ var DataController = class {
|
|
|
40869
41566
|
/**
|
|
40870
41567
|
* Gets the total number of refiners in the registry.
|
|
40871
41568
|
*
|
|
41569
|
+
* @remarks
|
|
41570
|
+
* Queries the DataRefinerRegistry contract to get the total count of all
|
|
41571
|
+
* registered refiners across all DLPs.
|
|
41572
|
+
*
|
|
40872
41573
|
* @returns Promise resolving to the total refiner count
|
|
41574
|
+
* @example
|
|
41575
|
+
* ```typescript
|
|
41576
|
+
* const count = await vana.data.getRefinersCount();
|
|
41577
|
+
* console.log(`Total refiners registered: ${count}`);
|
|
41578
|
+
* ```
|
|
40873
41579
|
*/
|
|
40874
41580
|
async getRefinersCount() {
|
|
40875
41581
|
try {
|
|
@@ -40897,8 +41603,24 @@ var DataController = class {
|
|
|
40897
41603
|
/**
|
|
40898
41604
|
* Updates the schema ID for an existing refiner.
|
|
40899
41605
|
*
|
|
40900
|
-
* @
|
|
41606
|
+
* @remarks
|
|
41607
|
+
* Allows the owner of a refiner to update its associated schema ID.
|
|
41608
|
+
* This is useful when refiner output format needs to change.
|
|
41609
|
+
*
|
|
41610
|
+
* @param params - Update parameters
|
|
41611
|
+
* @param params.refinerId - The refiner ID to update
|
|
41612
|
+
* @param params.newSchemaId - The new schema ID to set
|
|
40901
41613
|
* @returns Promise resolving to the transaction hash
|
|
41614
|
+
* @throws {Error} When chain ID is not available - "Chain ID not available"
|
|
41615
|
+
* @throws {Error} When transaction fails - "Failed to update schema ID: {error}"
|
|
41616
|
+
* @example
|
|
41617
|
+
* ```typescript
|
|
41618
|
+
* const result = await vana.data.updateSchemaId({
|
|
41619
|
+
* refinerId: 1,
|
|
41620
|
+
* newSchemaId: 55
|
|
41621
|
+
* });
|
|
41622
|
+
* console.log(`Schema updated in tx ${result.transactionHash}`);
|
|
41623
|
+
* ```
|
|
40902
41624
|
*/
|
|
40903
41625
|
async updateSchemaId(params) {
|
|
40904
41626
|
try {
|
|
@@ -41094,8 +41816,7 @@ var DataController = class {
|
|
|
41094
41816
|
* ```
|
|
41095
41817
|
*/
|
|
41096
41818
|
async addPermissionToFile(fileId, account, publicKey) {
|
|
41097
|
-
|
|
41098
|
-
return parseTransactionResult(this.context, txHash, "addFilePermission");
|
|
41819
|
+
return await this.submitFilePermission(fileId, account, publicKey);
|
|
41099
41820
|
}
|
|
41100
41821
|
/**
|
|
41101
41822
|
* Submits a file permission transaction and returns the transaction hash immediately.
|
|
@@ -41139,7 +41860,11 @@ var DataController = class {
|
|
|
41139
41860
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
41140
41861
|
chain: this.context.walletClient.chain || null
|
|
41141
41862
|
});
|
|
41142
|
-
return
|
|
41863
|
+
return new TransactionHandle(
|
|
41864
|
+
this.context,
|
|
41865
|
+
txHash,
|
|
41866
|
+
"addFilePermission"
|
|
41867
|
+
);
|
|
41143
41868
|
} catch (error) {
|
|
41144
41869
|
console.error("Failed to add permission to file:", error);
|
|
41145
41870
|
throw new Error(
|
|
@@ -41510,8 +42235,203 @@ var DataController = class {
|
|
|
41510
42235
|
}
|
|
41511
42236
|
};
|
|
41512
42237
|
|
|
42238
|
+
// src/generated/subgraph.ts
|
|
42239
|
+
var GetSchemaDocument = {
|
|
42240
|
+
kind: "Document",
|
|
42241
|
+
definitions: [
|
|
42242
|
+
{
|
|
42243
|
+
kind: "OperationDefinition",
|
|
42244
|
+
operation: "query",
|
|
42245
|
+
name: { kind: "Name", value: "GetSchema" },
|
|
42246
|
+
variableDefinitions: [
|
|
42247
|
+
{
|
|
42248
|
+
kind: "VariableDefinition",
|
|
42249
|
+
variable: { kind: "Variable", name: { kind: "Name", value: "id" } },
|
|
42250
|
+
type: {
|
|
42251
|
+
kind: "NonNullType",
|
|
42252
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
42253
|
+
}
|
|
42254
|
+
}
|
|
42255
|
+
],
|
|
42256
|
+
selectionSet: {
|
|
42257
|
+
kind: "SelectionSet",
|
|
42258
|
+
selections: [
|
|
42259
|
+
{
|
|
42260
|
+
kind: "Field",
|
|
42261
|
+
name: { kind: "Name", value: "schema" },
|
|
42262
|
+
arguments: [
|
|
42263
|
+
{
|
|
42264
|
+
kind: "Argument",
|
|
42265
|
+
name: { kind: "Name", value: "id" },
|
|
42266
|
+
value: {
|
|
42267
|
+
kind: "Variable",
|
|
42268
|
+
name: { kind: "Name", value: "id" }
|
|
42269
|
+
}
|
|
42270
|
+
}
|
|
42271
|
+
],
|
|
42272
|
+
selectionSet: {
|
|
42273
|
+
kind: "SelectionSet",
|
|
42274
|
+
selections: [
|
|
42275
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
42276
|
+
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
42277
|
+
{ kind: "Field", name: { kind: "Name", value: "dialect" } },
|
|
42278
|
+
{
|
|
42279
|
+
kind: "Field",
|
|
42280
|
+
name: { kind: "Name", value: "definitionUrl" }
|
|
42281
|
+
},
|
|
42282
|
+
{ kind: "Field", name: { kind: "Name", value: "createdAt" } },
|
|
42283
|
+
{
|
|
42284
|
+
kind: "Field",
|
|
42285
|
+
name: { kind: "Name", value: "createdAtBlock" }
|
|
42286
|
+
},
|
|
42287
|
+
{
|
|
42288
|
+
kind: "Field",
|
|
42289
|
+
name: { kind: "Name", value: "createdTxHash" }
|
|
42290
|
+
},
|
|
42291
|
+
{
|
|
42292
|
+
kind: "Field",
|
|
42293
|
+
name: { kind: "Name", value: "refiners" },
|
|
42294
|
+
selectionSet: {
|
|
42295
|
+
kind: "SelectionSet",
|
|
42296
|
+
selections: [
|
|
42297
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
42298
|
+
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
42299
|
+
{ kind: "Field", name: { kind: "Name", value: "owner" } }
|
|
42300
|
+
]
|
|
42301
|
+
}
|
|
42302
|
+
}
|
|
42303
|
+
]
|
|
42304
|
+
}
|
|
42305
|
+
}
|
|
42306
|
+
]
|
|
42307
|
+
}
|
|
42308
|
+
}
|
|
42309
|
+
]
|
|
42310
|
+
};
|
|
42311
|
+
var ListSchemasDocument = {
|
|
42312
|
+
kind: "Document",
|
|
42313
|
+
definitions: [
|
|
42314
|
+
{
|
|
42315
|
+
kind: "OperationDefinition",
|
|
42316
|
+
operation: "query",
|
|
42317
|
+
name: { kind: "Name", value: "ListSchemas" },
|
|
42318
|
+
variableDefinitions: [
|
|
42319
|
+
{
|
|
42320
|
+
kind: "VariableDefinition",
|
|
42321
|
+
variable: {
|
|
42322
|
+
kind: "Variable",
|
|
42323
|
+
name: { kind: "Name", value: "first" }
|
|
42324
|
+
},
|
|
42325
|
+
type: {
|
|
42326
|
+
kind: "NonNullType",
|
|
42327
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }
|
|
42328
|
+
}
|
|
42329
|
+
},
|
|
42330
|
+
{
|
|
42331
|
+
kind: "VariableDefinition",
|
|
42332
|
+
variable: { kind: "Variable", name: { kind: "Name", value: "skip" } },
|
|
42333
|
+
type: {
|
|
42334
|
+
kind: "NonNullType",
|
|
42335
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }
|
|
42336
|
+
}
|
|
42337
|
+
}
|
|
42338
|
+
],
|
|
42339
|
+
selectionSet: {
|
|
42340
|
+
kind: "SelectionSet",
|
|
42341
|
+
selections: [
|
|
42342
|
+
{
|
|
42343
|
+
kind: "Field",
|
|
42344
|
+
name: { kind: "Name", value: "schemas" },
|
|
42345
|
+
arguments: [
|
|
42346
|
+
{
|
|
42347
|
+
kind: "Argument",
|
|
42348
|
+
name: { kind: "Name", value: "first" },
|
|
42349
|
+
value: {
|
|
42350
|
+
kind: "Variable",
|
|
42351
|
+
name: { kind: "Name", value: "first" }
|
|
42352
|
+
}
|
|
42353
|
+
},
|
|
42354
|
+
{
|
|
42355
|
+
kind: "Argument",
|
|
42356
|
+
name: { kind: "Name", value: "skip" },
|
|
42357
|
+
value: {
|
|
42358
|
+
kind: "Variable",
|
|
42359
|
+
name: { kind: "Name", value: "skip" }
|
|
42360
|
+
}
|
|
42361
|
+
},
|
|
42362
|
+
{
|
|
42363
|
+
kind: "Argument",
|
|
42364
|
+
name: { kind: "Name", value: "orderBy" },
|
|
42365
|
+
value: { kind: "EnumValue", value: "createdAt" }
|
|
42366
|
+
},
|
|
42367
|
+
{
|
|
42368
|
+
kind: "Argument",
|
|
42369
|
+
name: { kind: "Name", value: "orderDirection" },
|
|
42370
|
+
value: { kind: "EnumValue", value: "desc" }
|
|
42371
|
+
}
|
|
42372
|
+
],
|
|
42373
|
+
selectionSet: {
|
|
42374
|
+
kind: "SelectionSet",
|
|
42375
|
+
selections: [
|
|
42376
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
42377
|
+
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
42378
|
+
{ kind: "Field", name: { kind: "Name", value: "dialect" } },
|
|
42379
|
+
{
|
|
42380
|
+
kind: "Field",
|
|
42381
|
+
name: { kind: "Name", value: "definitionUrl" }
|
|
42382
|
+
},
|
|
42383
|
+
{ kind: "Field", name: { kind: "Name", value: "createdAt" } },
|
|
42384
|
+
{
|
|
42385
|
+
kind: "Field",
|
|
42386
|
+
name: { kind: "Name", value: "createdAtBlock" }
|
|
42387
|
+
},
|
|
42388
|
+
{
|
|
42389
|
+
kind: "Field",
|
|
42390
|
+
name: { kind: "Name", value: "createdTxHash" }
|
|
42391
|
+
}
|
|
42392
|
+
]
|
|
42393
|
+
}
|
|
42394
|
+
}
|
|
42395
|
+
]
|
|
42396
|
+
}
|
|
42397
|
+
}
|
|
42398
|
+
]
|
|
42399
|
+
};
|
|
42400
|
+
var CountSchemasDocument = {
|
|
42401
|
+
kind: "Document",
|
|
42402
|
+
definitions: [
|
|
42403
|
+
{
|
|
42404
|
+
kind: "OperationDefinition",
|
|
42405
|
+
operation: "query",
|
|
42406
|
+
name: { kind: "Name", value: "CountSchemas" },
|
|
42407
|
+
selectionSet: {
|
|
42408
|
+
kind: "SelectionSet",
|
|
42409
|
+
selections: [
|
|
42410
|
+
{
|
|
42411
|
+
kind: "Field",
|
|
42412
|
+
name: { kind: "Name", value: "schemas" },
|
|
42413
|
+
arguments: [
|
|
42414
|
+
{
|
|
42415
|
+
kind: "Argument",
|
|
42416
|
+
name: { kind: "Name", value: "first" },
|
|
42417
|
+
value: { kind: "IntValue", value: "1000" }
|
|
42418
|
+
}
|
|
42419
|
+
],
|
|
42420
|
+
selectionSet: {
|
|
42421
|
+
kind: "SelectionSet",
|
|
42422
|
+
selections: [
|
|
42423
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } }
|
|
42424
|
+
]
|
|
42425
|
+
}
|
|
42426
|
+
}
|
|
42427
|
+
]
|
|
42428
|
+
}
|
|
42429
|
+
}
|
|
42430
|
+
]
|
|
42431
|
+
};
|
|
42432
|
+
|
|
41513
42433
|
// src/controllers/schemas.ts
|
|
41514
|
-
import {
|
|
42434
|
+
import { print } from "graphql";
|
|
41515
42435
|
var SchemaController = class {
|
|
41516
42436
|
constructor(context) {
|
|
41517
42437
|
this.context = context;
|
|
@@ -41613,30 +42533,14 @@ var SchemaController = class {
|
|
|
41613
42533
|
account: this.context.walletClient.account || userAddress,
|
|
41614
42534
|
chain: this.context.walletClient.chain || null
|
|
41615
42535
|
});
|
|
41616
|
-
const
|
|
41617
|
-
|
|
41618
|
-
|
|
41619
|
-
|
|
41620
|
-
// 30 seconds timeout
|
|
41621
|
-
}
|
|
42536
|
+
const txHandle = new TransactionHandle(
|
|
42537
|
+
this.context,
|
|
42538
|
+
txHash,
|
|
42539
|
+
"addSchema"
|
|
41622
42540
|
);
|
|
41623
|
-
|
|
41624
|
-
for (const log of receipt.logs) {
|
|
41625
|
-
try {
|
|
41626
|
-
const decoded = decodeEventLog2({
|
|
41627
|
-
abi: dataRefinerRegistryAbi,
|
|
41628
|
-
data: log.data,
|
|
41629
|
-
topics: log.topics
|
|
41630
|
-
});
|
|
41631
|
-
if (decoded.eventName === "SchemaAdded") {
|
|
41632
|
-
schemaId = Number(decoded.args.schemaId);
|
|
41633
|
-
break;
|
|
41634
|
-
}
|
|
41635
|
-
} catch {
|
|
41636
|
-
}
|
|
41637
|
-
}
|
|
42541
|
+
const result = await txHandle.waitForEvents();
|
|
41638
42542
|
return {
|
|
41639
|
-
schemaId,
|
|
42543
|
+
schemaId: Number(result.schemaId),
|
|
41640
42544
|
definitionUrl: uploadResult.url,
|
|
41641
42545
|
transactionHash: txHash
|
|
41642
42546
|
};
|
|
@@ -41653,15 +42557,30 @@ var SchemaController = class {
|
|
|
41653
42557
|
* Retrieves a schema by its ID.
|
|
41654
42558
|
*
|
|
41655
42559
|
* @param schemaId - The ID of the schema to retrieve
|
|
42560
|
+
* @param options - Optional parameters
|
|
42561
|
+
* @param options.subgraphUrl - Custom subgraph URL to use instead of default
|
|
41656
42562
|
* @returns Promise resolving to the schema object
|
|
41657
42563
|
* @throws {Error} When the schema is not found or chain is unavailable
|
|
41658
42564
|
* @example
|
|
41659
42565
|
* ```typescript
|
|
41660
42566
|
* const schema = await vana.schemas.get(1);
|
|
41661
42567
|
* console.log(`Schema: ${schema.name} (${schema.type})`);
|
|
42568
|
+
*
|
|
42569
|
+
* // With custom subgraph
|
|
42570
|
+
* const schema = await vana.schemas.get(1, {
|
|
42571
|
+
* subgraphUrl: 'https://custom-subgraph.com/graphql'
|
|
42572
|
+
* });
|
|
41662
42573
|
* ```
|
|
41663
42574
|
*/
|
|
41664
|
-
async get(schemaId) {
|
|
42575
|
+
async get(schemaId, options = {}) {
|
|
42576
|
+
const subgraphUrl = options.subgraphUrl || this.context.subgraphUrl;
|
|
42577
|
+
if (subgraphUrl) {
|
|
42578
|
+
try {
|
|
42579
|
+
return await this._getSchemaViaSubgraph({ schemaId, subgraphUrl });
|
|
42580
|
+
} catch (error) {
|
|
42581
|
+
console.debug("Subgraph query failed, falling back to RPC:", error);
|
|
42582
|
+
}
|
|
42583
|
+
}
|
|
41665
42584
|
try {
|
|
41666
42585
|
return await fetchSchemaFromChain(this.context, schemaId);
|
|
41667
42586
|
} catch (error) {
|
|
@@ -41673,15 +42592,30 @@ var SchemaController = class {
|
|
|
41673
42592
|
/**
|
|
41674
42593
|
* Gets the total number of schemas registered on the network.
|
|
41675
42594
|
*
|
|
42595
|
+
* @param options - Optional parameters
|
|
42596
|
+
* @param options.subgraphUrl - Custom subgraph URL to use instead of default
|
|
41676
42597
|
* @returns Promise resolving to the total schema count
|
|
41677
42598
|
* @throws {Error} When the count cannot be retrieved
|
|
41678
42599
|
* @example
|
|
41679
42600
|
* ```typescript
|
|
41680
42601
|
* const count = await vana.schemas.count();
|
|
41681
42602
|
* console.log(`Total schemas: ${count}`);
|
|
42603
|
+
*
|
|
42604
|
+
* // With custom subgraph
|
|
42605
|
+
* const count = await vana.schemas.count({
|
|
42606
|
+
* subgraphUrl: 'https://custom-subgraph.com/graphql'
|
|
42607
|
+
* });
|
|
41682
42608
|
* ```
|
|
41683
42609
|
*/
|
|
41684
|
-
async count() {
|
|
42610
|
+
async count(options = {}) {
|
|
42611
|
+
const subgraphUrl = options.subgraphUrl || this.context.subgraphUrl;
|
|
42612
|
+
if (subgraphUrl) {
|
|
42613
|
+
try {
|
|
42614
|
+
return await this._countSchemasViaSubgraph({ subgraphUrl });
|
|
42615
|
+
} catch (error) {
|
|
42616
|
+
console.debug("Subgraph query failed, falling back to RPC:", error);
|
|
42617
|
+
}
|
|
42618
|
+
}
|
|
41685
42619
|
try {
|
|
41686
42620
|
return await fetchSchemaCountFromChain(this.context);
|
|
41687
42621
|
} catch (error) {
|
|
@@ -41696,6 +42630,7 @@ var SchemaController = class {
|
|
|
41696
42630
|
* @param options - Optional parameters for listing schemas
|
|
41697
42631
|
* @param options.limit - Maximum number of schemas to return
|
|
41698
42632
|
* @param options.offset - Number of schemas to skip
|
|
42633
|
+
* @param options.subgraphUrl - Custom subgraph URL to use instead of default
|
|
41699
42634
|
* @returns Promise resolving to an array of schemas
|
|
41700
42635
|
* @example
|
|
41701
42636
|
* ```typescript
|
|
@@ -41704,23 +42639,78 @@ var SchemaController = class {
|
|
|
41704
42639
|
*
|
|
41705
42640
|
* // Get schemas with pagination
|
|
41706
42641
|
* const schemas = await vana.schemas.list({ limit: 10, offset: 0 });
|
|
42642
|
+
*
|
|
42643
|
+
* // With custom subgraph
|
|
42644
|
+
* const schemas = await vana.schemas.list({
|
|
42645
|
+
* limit: 10,
|
|
42646
|
+
* offset: 0,
|
|
42647
|
+
* subgraphUrl: 'https://custom-subgraph.com/graphql'
|
|
42648
|
+
* });
|
|
41707
42649
|
* ```
|
|
41708
42650
|
*/
|
|
41709
42651
|
async list(options = {}) {
|
|
41710
42652
|
const { limit = 100, offset = 0 } = options;
|
|
42653
|
+
const subgraphUrl = options.subgraphUrl || this.context.subgraphUrl;
|
|
42654
|
+
if (subgraphUrl) {
|
|
42655
|
+
try {
|
|
42656
|
+
return await this._listSchemasViaSubgraph({
|
|
42657
|
+
limit,
|
|
42658
|
+
offset,
|
|
42659
|
+
subgraphUrl
|
|
42660
|
+
});
|
|
42661
|
+
} catch (error) {
|
|
42662
|
+
console.debug("Subgraph query failed, falling back to RPC:", error);
|
|
42663
|
+
}
|
|
42664
|
+
}
|
|
41711
42665
|
try {
|
|
41712
42666
|
const totalCount = await this.count();
|
|
41713
|
-
const schemas = [];
|
|
41714
42667
|
const start = offset;
|
|
41715
42668
|
const end = Math.min(start + limit, totalCount);
|
|
42669
|
+
if (end <= start) {
|
|
42670
|
+
return [];
|
|
42671
|
+
}
|
|
42672
|
+
const chainId = this.context.walletClient.chain?.id;
|
|
42673
|
+
if (!chainId) {
|
|
42674
|
+
throw new Error("Chain ID not available");
|
|
42675
|
+
}
|
|
42676
|
+
const dataRefinerRegistryAddress = getContractAddress(
|
|
42677
|
+
chainId,
|
|
42678
|
+
"DataRefinerRegistry"
|
|
42679
|
+
);
|
|
42680
|
+
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
42681
|
+
const schemaCalls = [];
|
|
41716
42682
|
for (let i = start; i < end; i++) {
|
|
41717
|
-
|
|
41718
|
-
|
|
41719
|
-
|
|
41720
|
-
|
|
41721
|
-
|
|
41722
|
-
|
|
42683
|
+
schemaCalls.push({
|
|
42684
|
+
address: dataRefinerRegistryAddress,
|
|
42685
|
+
abi: dataRefinerRegistryAbi,
|
|
42686
|
+
functionName: "schemas",
|
|
42687
|
+
args: [BigInt(i + 1)]
|
|
42688
|
+
// Schema IDs are 1-based
|
|
42689
|
+
});
|
|
41723
42690
|
}
|
|
42691
|
+
const schemaResults = await gasAwareMulticall(this.context.publicClient, {
|
|
42692
|
+
contracts: schemaCalls,
|
|
42693
|
+
allowFailure: true
|
|
42694
|
+
});
|
|
42695
|
+
const schemas = [];
|
|
42696
|
+
schemaResults.forEach((result, index) => {
|
|
42697
|
+
if (result.status === "success" && result.result) {
|
|
42698
|
+
const schemaId = start + index + 1;
|
|
42699
|
+
const schemaData = result.result;
|
|
42700
|
+
if (schemaData.name && schemaData.dialect && schemaData.definitionUrl) {
|
|
42701
|
+
schemas.push({
|
|
42702
|
+
id: schemaId,
|
|
42703
|
+
name: schemaData.name,
|
|
42704
|
+
dialect: schemaData.dialect,
|
|
42705
|
+
definitionUrl: schemaData.definitionUrl
|
|
42706
|
+
});
|
|
42707
|
+
} else {
|
|
42708
|
+
console.warn(`Incomplete schema data for ID ${schemaId}`);
|
|
42709
|
+
}
|
|
42710
|
+
} else {
|
|
42711
|
+
console.warn(`Failed to retrieve schema ${start + index + 1}`);
|
|
42712
|
+
}
|
|
42713
|
+
});
|
|
41724
42714
|
return schemas;
|
|
41725
42715
|
} catch (error) {
|
|
41726
42716
|
throw new Error(
|
|
@@ -41751,7 +42741,7 @@ var SchemaController = class {
|
|
|
41751
42741
|
address: dataRefinerRegistryAddress,
|
|
41752
42742
|
abi: dataRefinerRegistryAbi,
|
|
41753
42743
|
functionName: "addSchema",
|
|
41754
|
-
args: [params.name, params.
|
|
42744
|
+
args: [params.name, params.dialect, params.definitionUrl],
|
|
41755
42745
|
account: this.context.walletClient.account || userAddress,
|
|
41756
42746
|
chain: this.context.walletClient.chain || null
|
|
41757
42747
|
});
|
|
@@ -41766,6 +42756,119 @@ var SchemaController = class {
|
|
|
41766
42756
|
);
|
|
41767
42757
|
}
|
|
41768
42758
|
}
|
|
42759
|
+
/**
|
|
42760
|
+
* Internal method: Query schema via subgraph
|
|
42761
|
+
*
|
|
42762
|
+
* @param params - Query parameters
|
|
42763
|
+
* @param params.schemaId - The ID of the schema to retrieve
|
|
42764
|
+
* @param params.subgraphUrl - The subgraph URL to query
|
|
42765
|
+
* @returns Promise resolving to the schema object
|
|
42766
|
+
* @private
|
|
42767
|
+
*/
|
|
42768
|
+
async _getSchemaViaSubgraph(params) {
|
|
42769
|
+
const { schemaId, subgraphUrl } = params;
|
|
42770
|
+
const response = await fetch(subgraphUrl, {
|
|
42771
|
+
method: "POST",
|
|
42772
|
+
headers: { "Content-Type": "application/json" },
|
|
42773
|
+
body: JSON.stringify({
|
|
42774
|
+
query: print(GetSchemaDocument),
|
|
42775
|
+
variables: { id: schemaId.toString() }
|
|
42776
|
+
})
|
|
42777
|
+
});
|
|
42778
|
+
if (!response.ok) {
|
|
42779
|
+
throw new Error(
|
|
42780
|
+
`Subgraph request failed: ${response.status} ${response.statusText}`
|
|
42781
|
+
);
|
|
42782
|
+
}
|
|
42783
|
+
const result = await response.json();
|
|
42784
|
+
if (result.errors) {
|
|
42785
|
+
throw new Error(
|
|
42786
|
+
`Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
42787
|
+
);
|
|
42788
|
+
}
|
|
42789
|
+
if (!result.data?.schema) {
|
|
42790
|
+
throw new Error(`Schema ${schemaId} not found in subgraph`);
|
|
42791
|
+
}
|
|
42792
|
+
const subgraphSchema = result.data.schema;
|
|
42793
|
+
return {
|
|
42794
|
+
id: parseInt(subgraphSchema.id),
|
|
42795
|
+
name: subgraphSchema.name,
|
|
42796
|
+
dialect: subgraphSchema.dialect,
|
|
42797
|
+
definitionUrl: subgraphSchema.definitionUrl
|
|
42798
|
+
};
|
|
42799
|
+
}
|
|
42800
|
+
/**
|
|
42801
|
+
* Internal method: List schemas via subgraph
|
|
42802
|
+
*
|
|
42803
|
+
* @param params - Query parameters
|
|
42804
|
+
* @param params.limit - Maximum number of schemas to return
|
|
42805
|
+
* @param params.offset - Number of schemas to skip
|
|
42806
|
+
* @param params.subgraphUrl - The subgraph URL to query
|
|
42807
|
+
* @returns Promise resolving to an array of schemas
|
|
42808
|
+
* @private
|
|
42809
|
+
*/
|
|
42810
|
+
async _listSchemasViaSubgraph(params) {
|
|
42811
|
+
const { limit, offset, subgraphUrl } = params;
|
|
42812
|
+
const response = await fetch(subgraphUrl, {
|
|
42813
|
+
method: "POST",
|
|
42814
|
+
headers: { "Content-Type": "application/json" },
|
|
42815
|
+
body: JSON.stringify({
|
|
42816
|
+
query: print(ListSchemasDocument),
|
|
42817
|
+
variables: { first: limit, skip: offset }
|
|
42818
|
+
})
|
|
42819
|
+
});
|
|
42820
|
+
if (!response.ok) {
|
|
42821
|
+
throw new Error(
|
|
42822
|
+
`Subgraph request failed: ${response.status} ${response.statusText}`
|
|
42823
|
+
);
|
|
42824
|
+
}
|
|
42825
|
+
const result = await response.json();
|
|
42826
|
+
if (result.errors) {
|
|
42827
|
+
throw new Error(
|
|
42828
|
+
`Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
42829
|
+
);
|
|
42830
|
+
}
|
|
42831
|
+
if (!result.data?.schemas) {
|
|
42832
|
+
return [];
|
|
42833
|
+
}
|
|
42834
|
+
return result.data.schemas.map((schema) => ({
|
|
42835
|
+
id: parseInt(schema.id),
|
|
42836
|
+
name: schema.name,
|
|
42837
|
+
dialect: schema.dialect,
|
|
42838
|
+
definitionUrl: schema.definitionUrl
|
|
42839
|
+
}));
|
|
42840
|
+
}
|
|
42841
|
+
/**
|
|
42842
|
+
* Internal method: Count schemas via subgraph
|
|
42843
|
+
*
|
|
42844
|
+
* @param params - Query parameters
|
|
42845
|
+
* @param params.subgraphUrl - The subgraph URL to query
|
|
42846
|
+
* @returns Promise resolving to the total schema count
|
|
42847
|
+
* @private
|
|
42848
|
+
*/
|
|
42849
|
+
async _countSchemasViaSubgraph(params) {
|
|
42850
|
+
const { subgraphUrl } = params;
|
|
42851
|
+
const response = await fetch(subgraphUrl, {
|
|
42852
|
+
method: "POST",
|
|
42853
|
+
headers: { "Content-Type": "application/json" },
|
|
42854
|
+
body: JSON.stringify({
|
|
42855
|
+
query: print(CountSchemasDocument),
|
|
42856
|
+
variables: {}
|
|
42857
|
+
})
|
|
42858
|
+
});
|
|
42859
|
+
if (!response.ok) {
|
|
42860
|
+
throw new Error(
|
|
42861
|
+
`Subgraph request failed: ${response.status} ${response.statusText}`
|
|
42862
|
+
);
|
|
42863
|
+
}
|
|
42864
|
+
const result = await response.json();
|
|
42865
|
+
if (result.errors) {
|
|
42866
|
+
throw new Error(
|
|
42867
|
+
`Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
42868
|
+
);
|
|
42869
|
+
}
|
|
42870
|
+
return result.data?.schemas?.length || 0;
|
|
42871
|
+
}
|
|
41769
42872
|
/**
|
|
41770
42873
|
* Gets the user's wallet address.
|
|
41771
42874
|
*
|
|
@@ -42206,7 +43309,12 @@ var chains = {
|
|
|
42206
43309
|
};
|
|
42207
43310
|
|
|
42208
43311
|
// src/core/client.ts
|
|
42209
|
-
var
|
|
43312
|
+
var defaultFromBlocks = {
|
|
43313
|
+
14800: BigInt(732312),
|
|
43314
|
+
// Moksha Testnet - earliest contract deployment
|
|
43315
|
+
1480: BigInt(758584)
|
|
43316
|
+
// Vana Mainnet - earliest contract deployment
|
|
43317
|
+
};
|
|
42210
43318
|
var _client;
|
|
42211
43319
|
var createClient = (chainId = mokshaTestnet.id) => {
|
|
42212
43320
|
if (!_client || _client.chain?.id !== chainId) {
|
|
@@ -43853,7 +44961,7 @@ var vanaMainnet2 = {
|
|
|
43853
44961
|
url: "https://vanascan.io"
|
|
43854
44962
|
}
|
|
43855
44963
|
},
|
|
43856
|
-
subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/vana/7.0.
|
|
44964
|
+
subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/vana/7.0.7/gn"
|
|
43857
44965
|
};
|
|
43858
44966
|
var moksha = {
|
|
43859
44967
|
id: 14800,
|
|
@@ -43874,7 +44982,7 @@ var moksha = {
|
|
|
43874
44982
|
url: "https://moksha.vanascan.io"
|
|
43875
44983
|
}
|
|
43876
44984
|
},
|
|
43877
|
-
subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/moksha/7.0.
|
|
44985
|
+
subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/moksha/7.0.7/gn"
|
|
43878
44986
|
};
|
|
43879
44987
|
function getChainConfig(chainId) {
|
|
43880
44988
|
switch (chainId) {
|
|
@@ -45217,6 +46325,7 @@ export {
|
|
|
45217
46325
|
SignatureError,
|
|
45218
46326
|
StorageError,
|
|
45219
46327
|
StorageManager,
|
|
46328
|
+
TransactionHandle,
|
|
45220
46329
|
UserRejectedRequestError,
|
|
45221
46330
|
Vana,
|
|
45222
46331
|
VanaBrowserImpl,
|