@xandeum/web3.js 1.6.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -38,7 +38,8 @@ import {
38
38
  import {
39
39
  Connection,
40
40
  sendAndConfirmTransaction,
41
- Keypair
41
+ Keypair,
42
+ PublicKey
42
43
  } from '@solana/web3.js'
43
44
 
44
45
  const connection = new Connection('https://apis.devnet.xandeum.com)
@@ -54,6 +55,8 @@ async function main() {
54
55
  const tx2 = await createFile('1', '/','hello.txt', wallet)
55
56
  await sendAndConfirmTransaction(connection, tx2, [signer])
56
57
 
58
+ const dataAccount = new PublicKey("FBM4G63KPUneqyLwQy6zVu81AsMqmkQjsdxNGBKq3dkv");
59
+
57
60
  // Write data
58
61
  const tx3 = await poke('1', '/hello.txt', 0, Buffer.from('Hello Xandeum!'), wallet)
59
62
  await sendAndConfirmTransaction(connection, tx3, [signer])
package/dist/exists.js CHANGED
@@ -51,7 +51,7 @@ exports.exists = exists;
51
51
  */
52
52
  function exists(connection, path) {
53
53
  return __awaiter(this, void 0, void 0, function () {
54
- var url, requestBody, response, data;
54
+ var url, requestBody, response, errorText, data;
55
55
  return __generator(this, function (_a) {
56
56
  switch (_a.label) {
57
57
  case 0:
@@ -71,11 +71,13 @@ function exists(connection, path) {
71
71
  })];
72
72
  case 1:
73
73
  response = _a.sent();
74
- if (!response.ok) {
75
- throw new Error("HTTP error! Status: ".concat(response.status));
76
- }
77
- return [4 /*yield*/, response.json()];
74
+ if (!!response.ok) return [3 /*break*/, 3];
75
+ return [4 /*yield*/, response.text()];
78
76
  case 2:
77
+ errorText = _a.sent();
78
+ return [2 /*return*/, Error("error! status: ".concat(response.status, ", message: ").concat(errorText))];
79
+ case 3: return [4 /*yield*/, response.json()];
80
+ case 4:
79
81
  data = _a.sent();
80
82
  return [2 /*return*/, data];
81
83
  }
@@ -54,7 +54,7 @@ exports.getMetadata = getMetadata;
54
54
  */
55
55
  function getMetadata(connection, path) {
56
56
  return __awaiter(this, void 0, void 0, function () {
57
- var url, requestBody, response, data;
57
+ var url, requestBody, response, errorText, data;
58
58
  return __generator(this, function (_a) {
59
59
  switch (_a.label) {
60
60
  case 0:
@@ -74,11 +74,13 @@ function getMetadata(connection, path) {
74
74
  })];
75
75
  case 1:
76
76
  response = _a.sent();
77
- if (!response.ok) {
78
- throw new Error("HTTP error! Status: ".concat(response.status));
79
- }
80
- return [4 /*yield*/, response.json()];
77
+ if (!!response.ok) return [3 /*break*/, 3];
78
+ return [4 /*yield*/, response.text()];
81
79
  case 2:
80
+ errorText = _a.sent();
81
+ return [2 /*return*/, Error("error! status: ".concat(response.status, ", message: ").concat(errorText))];
82
+ case 3: return [4 /*yield*/, response.json()];
83
+ case 4:
82
84
  data = _a.sent();
83
85
  return [2 /*return*/, data];
84
86
  }
@@ -52,7 +52,7 @@ exports.listDirectoryEntry = listDirectoryEntry;
52
52
  */
53
53
  function listDirectoryEntry(connection, path) {
54
54
  return __awaiter(this, void 0, void 0, function () {
55
- var url, requestBody, response, data;
55
+ var url, requestBody, response, errorText, data;
56
56
  return __generator(this, function (_a) {
57
57
  switch (_a.label) {
58
58
  case 0:
@@ -72,11 +72,13 @@ function listDirectoryEntry(connection, path) {
72
72
  })];
73
73
  case 1:
74
74
  response = _a.sent();
75
- if (!response.ok) {
76
- throw new Error("HTTP error! Status: ".concat(response.status));
77
- }
78
- return [4 /*yield*/, response.json()];
75
+ if (!!response.ok) return [3 /*break*/, 3];
76
+ return [4 /*yield*/, response.text()];
79
77
  case 2:
78
+ errorText = _a.sent();
79
+ return [2 /*return*/, Error("error! status: ".concat(response.status, ", message: ").concat(errorText))];
80
+ case 3: return [4 /*yield*/, response.json()];
81
+ case 4:
80
82
  data = _a.sent();
81
83
  return [2 /*return*/, data];
82
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xandeum/web3.js",
3
- "version": "1.6.0",
3
+ "version": "1.8.0",
4
4
  "description": "Xandeum javascript api",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/exists.ts CHANGED
@@ -38,7 +38,8 @@ export interface RpcRequest {
38
38
  })
39
39
 
40
40
  if (!response.ok) {
41
- throw new Error(`HTTP error! Status: ${response.status}`)
41
+ const errorText = await response.text();
42
+ return Error(`error! status: ${response.status}, message: ${errorText}`);
42
43
  }
43
44
 
44
45
  const data = await response.json()
@@ -41,7 +41,8 @@ export async function getMetadata (connection: Connection,path: string): Promise
41
41
  })
42
42
 
43
43
  if (!response.ok) {
44
- throw new Error(`HTTP error! Status: ${response.status}`)
44
+ const errorText = await response.text();
45
+ return Error(`error! status: ${response.status}, message: ${errorText}`);
45
46
  }
46
47
 
47
48
  const data = await response.json()
@@ -42,7 +42,8 @@ export async function listDirectoryEntry (
42
42
  })
43
43
 
44
44
  if (!response.ok) {
45
- throw new Error(`HTTP error! Status: ${response.status}`)
45
+ const errorText = await response.text();
46
+ return Error(`error! status: ${response.status}, message: ${errorText}`);
46
47
  }
47
48
 
48
49
  const data = await response.json()