wao 0.35.2 → 0.35.4
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/cjs/hb.js +20 -27
- package/cjs/workspace/package.json +1 -1
- package/esm/hb.js +11 -11
- package/esm/workspace/package.json +1 -1
- package/package.json +1 -1
package/cjs/hb.js
CHANGED
|
@@ -79,18 +79,12 @@ var HB = /*#__PURE__*/function () {
|
|
|
79
79
|
}
|
|
80
80
|
return signEncoded;
|
|
81
81
|
}()
|
|
82
|
-
}, {
|
|
83
|
-
key: "isArConnect",
|
|
84
|
-
value: function isArConnect() {
|
|
85
|
-
var _this$jwk, _this$jwk2;
|
|
86
|
-
return ((_this$jwk = this.jwk) === null || _this$jwk === void 0 ? void 0 : _this$jwk.id) || ((_this$jwk2 = this.jwk) === null || _this$jwk2 === void 0 ? void 0 : _this$jwk2.walletName) === "ArConnect";
|
|
87
|
-
}
|
|
88
82
|
}, {
|
|
89
83
|
key: "_init",
|
|
90
84
|
value: function _init(jwk) {
|
|
91
85
|
this.jwk = jwk;
|
|
92
86
|
this.signer = (0, _aoconnect.createSigner)(jwk, this.url);
|
|
93
|
-
|
|
87
|
+
this.addr = (0, _utils.toAddr)(jwk.n);
|
|
94
88
|
this.sign = (0, _hbsig.signer)({
|
|
95
89
|
signer: this.signer,
|
|
96
90
|
url: this.url
|
|
@@ -103,26 +97,26 @@ var HB = /*#__PURE__*/function () {
|
|
|
103
97
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
104
98
|
while (1) switch (_context2.prev = _context2.next) {
|
|
105
99
|
case 0:
|
|
106
|
-
if (this.
|
|
100
|
+
if (this.operator) {
|
|
107
101
|
_context2.next = 10;
|
|
108
102
|
break;
|
|
109
103
|
}
|
|
110
104
|
_context2.prev = 1;
|
|
111
105
|
_context2.next = 4;
|
|
112
|
-
return this.g("/~meta@1.0/info");
|
|
106
|
+
return this.g("/~meta@1.0/info/address");
|
|
113
107
|
case 4:
|
|
114
|
-
this.
|
|
115
|
-
this.operator = this._info.address;
|
|
108
|
+
this.operator = _context2.sent;
|
|
116
109
|
_context2.next = 10;
|
|
117
110
|
break;
|
|
118
|
-
case
|
|
119
|
-
_context2.prev =
|
|
111
|
+
case 7:
|
|
112
|
+
_context2.prev = 7;
|
|
120
113
|
_context2.t0 = _context2["catch"](1);
|
|
114
|
+
console.log(_context2.t0);
|
|
121
115
|
case 10:
|
|
122
116
|
case "end":
|
|
123
117
|
return _context2.stop();
|
|
124
118
|
}
|
|
125
|
-
}, _callee2, this, [[1,
|
|
119
|
+
}, _callee2, this, [[1, 7]]);
|
|
126
120
|
}));
|
|
127
121
|
function setInfo() {
|
|
128
122
|
return _setInfo.apply(this, arguments);
|
|
@@ -942,7 +936,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
942
936
|
t = (0, _ramda.mergeLeft)(tags, {
|
|
943
937
|
"data-protocol": "ao",
|
|
944
938
|
variant: "ao.TN.1",
|
|
945
|
-
authority: this.
|
|
939
|
+
authority: this.operator,
|
|
946
940
|
module: module !== null && module !== void 0 ? module : "ISShJH1ij-hPPt9St5UFFr_8Ys3Kj5cyg7zrMGt7H9s",
|
|
947
941
|
device: "process@1.0",
|
|
948
942
|
"execution-device": "stack@1.0",
|
|
@@ -1065,16 +1059,13 @@ var HB = /*#__PURE__*/function () {
|
|
|
1065
1059
|
while (1) switch (_context29.prev = _context29.next) {
|
|
1066
1060
|
case 0:
|
|
1067
1061
|
_ref17 = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {}, _ref17$tags = _ref17.tags, tags = _ref17$tags === void 0 ? {} : _ref17$tags, pid = _ref17.pid, action = _ref17.action, data = _ref17.data;
|
|
1068
|
-
_context29.next = 3;
|
|
1069
|
-
return this.setInfo();
|
|
1070
|
-
case 3:
|
|
1071
1062
|
if (typeof action === "string") tags.Action = action;
|
|
1072
1063
|
json = {
|
|
1073
1064
|
Tags: (0, _utils.buildTags)(_objectSpread({}, tags)),
|
|
1074
|
-
Owner: this.
|
|
1065
|
+
Owner: this.addr
|
|
1075
1066
|
};
|
|
1076
1067
|
if (data) json.Data = data;
|
|
1077
|
-
_context29.next =
|
|
1068
|
+
_context29.next = 6;
|
|
1078
1069
|
return this.post({
|
|
1079
1070
|
path: "/~relay@1.0/call",
|
|
1080
1071
|
method: "POST",
|
|
@@ -1082,10 +1073,10 @@ var HB = /*#__PURE__*/function () {
|
|
|
1082
1073
|
"content-type": "application/json",
|
|
1083
1074
|
"relay-body": JSON.stringify(json)
|
|
1084
1075
|
});
|
|
1085
|
-
case
|
|
1076
|
+
case 6:
|
|
1086
1077
|
res = _context29.sent;
|
|
1087
1078
|
return _context29.abrupt("return", JSON.parse(res.body));
|
|
1088
|
-
case
|
|
1079
|
+
case 8:
|
|
1089
1080
|
case "end":
|
|
1090
1081
|
return _context29.stop();
|
|
1091
1082
|
}
|
|
@@ -1325,18 +1316,20 @@ var HB = /*#__PURE__*/function () {
|
|
|
1325
1316
|
i++;
|
|
1326
1317
|
}
|
|
1327
1318
|
}
|
|
1328
|
-
|
|
1319
|
+
console.log("".concat(this.url).concat(path).concat(_json).concat(_params));
|
|
1320
|
+
_context34.next = 10;
|
|
1329
1321
|
return fetch("".concat(this.url).concat(path).concat(_json).concat(_params));
|
|
1330
|
-
case
|
|
1322
|
+
case 10:
|
|
1331
1323
|
response = _context34.sent;
|
|
1324
|
+
console.log(response);
|
|
1332
1325
|
headers = {};
|
|
1333
1326
|
response.headers.forEach(function (v, k) {
|
|
1334
1327
|
return headers[k] = v;
|
|
1335
1328
|
});
|
|
1336
1329
|
_context34.t0 = headers;
|
|
1337
|
-
_context34.next =
|
|
1330
|
+
_context34.next = 17;
|
|
1338
1331
|
return response.text();
|
|
1339
|
-
case
|
|
1332
|
+
case 17:
|
|
1340
1333
|
_context34.t1 = _context34.sent;
|
|
1341
1334
|
_context34.t2 = response.status;
|
|
1342
1335
|
http = {
|
|
@@ -1345,7 +1338,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
1345
1338
|
status: _context34.t2
|
|
1346
1339
|
};
|
|
1347
1340
|
return _context34.abrupt("return", _objectSpread(_objectSpread({}, (0, _httpsigUtils.from)(http)), http));
|
|
1348
|
-
case
|
|
1341
|
+
case 21:
|
|
1349
1342
|
case "end":
|
|
1350
1343
|
return _context34.stop();
|
|
1351
1344
|
}
|
package/esm/hb.js
CHANGED
|
@@ -25,22 +25,21 @@ class HB {
|
|
|
25
25
|
url: this.url,
|
|
26
26
|
})
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
return this.jwk?.id || this.jwk?.walletName === "ArConnect"
|
|
30
|
-
}
|
|
28
|
+
|
|
31
29
|
_init(jwk) {
|
|
32
30
|
this.jwk = jwk
|
|
33
31
|
this.signer = createSigner(jwk, this.url)
|
|
34
|
-
|
|
32
|
+
this.addr = toAddr(jwk.n)
|
|
35
33
|
this.sign = signer({ signer: this.signer, url: this.url })
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
async setInfo() {
|
|
39
|
-
if (!this.
|
|
37
|
+
if (!this.operator) {
|
|
40
38
|
try {
|
|
41
|
-
this.
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
this.operator = await this.g("/~meta@1.0/info/address")
|
|
40
|
+
} catch (e) {
|
|
41
|
+
console.log(e)
|
|
42
|
+
}
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
|
|
@@ -214,7 +213,7 @@ class HB {
|
|
|
214
213
|
let t = mergeLeft(tags, {
|
|
215
214
|
"data-protocol": "ao",
|
|
216
215
|
variant: "ao.TN.1",
|
|
217
|
-
authority: this.
|
|
216
|
+
authority: this.operator,
|
|
218
217
|
module: module ?? "ISShJH1ij-hPPt9St5UFFr_8Ys3Kj5cyg7zrMGt7H9s",
|
|
219
218
|
device: "process@1.0",
|
|
220
219
|
"execution-device": "stack@1.0",
|
|
@@ -250,9 +249,8 @@ class HB {
|
|
|
250
249
|
}
|
|
251
250
|
|
|
252
251
|
async dryrun({ tags = {}, pid, action, data } = {}) {
|
|
253
|
-
await this.setInfo()
|
|
254
252
|
if (typeof action === "string") tags.Action = action
|
|
255
|
-
let json = { Tags: buildTags({ ...tags }), Owner: this.
|
|
253
|
+
let json = { Tags: buildTags({ ...tags }), Owner: this.addr }
|
|
256
254
|
if (data) json.Data = data
|
|
257
255
|
const res = await this.post({
|
|
258
256
|
path: "/~relay@1.0/call",
|
|
@@ -301,7 +299,9 @@ class HB {
|
|
|
301
299
|
i++
|
|
302
300
|
}
|
|
303
301
|
}
|
|
302
|
+
console.log(`${this.url}${path}${_json}${_params}`)
|
|
304
303
|
const response = await fetch(`${this.url}${path}${_json}${_params}`)
|
|
304
|
+
console.log(response)
|
|
305
305
|
let headers = {}
|
|
306
306
|
response.headers.forEach((v, k) => (headers[k] = v))
|
|
307
307
|
const http = {
|