wao 0.36.3 → 0.36.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/bundler.js +36 -32
- package/esm/bundler.js +67 -65
- package/package.json +1 -1
package/cjs/bundler.js
CHANGED
|
@@ -57,11 +57,15 @@ var bundler = function bundler() {
|
|
|
57
57
|
_context2.t0 = _regeneratorRuntime().keys((_out$body$commitments = (_out$body = out.body) === null || _out$body === void 0 ? void 0 : _out$body.commitments) !== null && _out$body$commitments !== void 0 ? _out$body$commitments : {});
|
|
58
58
|
case 7:
|
|
59
59
|
if ((_context2.t1 = _context2.t0()).done) {
|
|
60
|
-
_context2.next =
|
|
60
|
+
_context2.next = 58;
|
|
61
61
|
break;
|
|
62
62
|
}
|
|
63
63
|
k = _context2.t1.value;
|
|
64
64
|
msg = (_out$body2 = out.body) === null || _out$body2 === void 0 ? void 0 : _out$body2.commitments[k];
|
|
65
|
+
if (!(msg["commitment-device"] === "ans104@1.0")) {
|
|
66
|
+
_context2.next = 56;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
65
69
|
signer = {
|
|
66
70
|
signatureType: 1,
|
|
67
71
|
signatureLength: 512,
|
|
@@ -101,14 +105,14 @@ var bundler = function bundler() {
|
|
|
101
105
|
tags: tags
|
|
102
106
|
};
|
|
103
107
|
if (type !== "Process") opt.target = out.process;
|
|
104
|
-
_context2.next =
|
|
108
|
+
_context2.next = 19;
|
|
105
109
|
return (0, _arbundles.createData)(out.data || "", signer, opt);
|
|
106
|
-
case
|
|
110
|
+
case 19:
|
|
107
111
|
di = _context2.sent;
|
|
108
|
-
_context2.next =
|
|
112
|
+
_context2.next = 22;
|
|
109
113
|
return di.setSignature(msg.signature);
|
|
110
|
-
case
|
|
111
|
-
_context2.next =
|
|
114
|
+
case 22:
|
|
115
|
+
_context2.next = 24;
|
|
112
116
|
return fetch("https://up.arweave.net:443/tx", {
|
|
113
117
|
method: "POST",
|
|
114
118
|
headers: {
|
|
@@ -116,40 +120,40 @@ var bundler = function bundler() {
|
|
|
116
120
|
},
|
|
117
121
|
body: di.binary
|
|
118
122
|
});
|
|
119
|
-
case
|
|
123
|
+
case 24:
|
|
120
124
|
_res = _context2.sent;
|
|
121
125
|
console.log(_res === null || _res === void 0 ? void 0 : _res.status, di.tags);
|
|
122
126
|
dis = [di];
|
|
123
127
|
if (!(type === "Message")) {
|
|
124
|
-
_context2.next =
|
|
128
|
+
_context2.next = 56;
|
|
125
129
|
break;
|
|
126
130
|
}
|
|
127
131
|
if (out["block-timestamp"]) {
|
|
128
|
-
_context2.next =
|
|
132
|
+
_context2.next = 42;
|
|
129
133
|
break;
|
|
130
134
|
}
|
|
131
|
-
_context2.prev =
|
|
135
|
+
_context2.prev = 29;
|
|
132
136
|
if (!(Date.now() - last_checked > timeout)) {
|
|
133
|
-
_context2.next =
|
|
137
|
+
_context2.next = 37;
|
|
134
138
|
break;
|
|
135
139
|
}
|
|
136
|
-
_context2.next =
|
|
140
|
+
_context2.next = 33;
|
|
137
141
|
return fetch("https://arweave.net/block/current").then(function (r) {
|
|
138
142
|
return r.json();
|
|
139
143
|
});
|
|
140
|
-
case
|
|
144
|
+
case 33:
|
|
141
145
|
json = _context2.sent;
|
|
142
146
|
height = json.height;
|
|
143
147
|
timestamp = json.timestamp;
|
|
144
148
|
last_checked = Date.now();
|
|
145
|
-
case
|
|
146
|
-
_context2.next =
|
|
149
|
+
case 37:
|
|
150
|
+
_context2.next = 42;
|
|
147
151
|
break;
|
|
148
|
-
case
|
|
149
|
-
_context2.prev =
|
|
150
|
-
_context2.t2 = _context2["catch"](
|
|
152
|
+
case 39:
|
|
153
|
+
_context2.prev = 39;
|
|
154
|
+
_context2.t2 = _context2["catch"](29);
|
|
151
155
|
console.log(_context2.t2);
|
|
152
|
-
case
|
|
156
|
+
case 42:
|
|
153
157
|
atags = {
|
|
154
158
|
Process: out.process,
|
|
155
159
|
Epoch: out.epoch,
|
|
@@ -171,17 +175,17 @@ var bundler = function bundler() {
|
|
|
171
175
|
});
|
|
172
176
|
}
|
|
173
177
|
_signer = new _turboSdk.ArweaveSigner(jwk);
|
|
174
|
-
_context2.next =
|
|
178
|
+
_context2.next = 48;
|
|
175
179
|
return (0, _arbundles.createData)("", _signer, {
|
|
176
180
|
tags: _tags
|
|
177
181
|
});
|
|
178
|
-
case
|
|
182
|
+
case 48:
|
|
179
183
|
di2 = _context2.sent;
|
|
180
|
-
_context2.next =
|
|
184
|
+
_context2.next = 51;
|
|
181
185
|
return di2.sign(_signer);
|
|
182
|
-
case
|
|
186
|
+
case 51:
|
|
183
187
|
dis.push(di2);
|
|
184
|
-
_context2.next =
|
|
188
|
+
_context2.next = 54;
|
|
185
189
|
return fetch("https://up.arweave.net:443/tx", {
|
|
186
190
|
method: "POST",
|
|
187
191
|
headers: {
|
|
@@ -189,24 +193,24 @@ var bundler = function bundler() {
|
|
|
189
193
|
},
|
|
190
194
|
body: di2.binary
|
|
191
195
|
});
|
|
192
|
-
case
|
|
196
|
+
case 54:
|
|
193
197
|
res2 = _context2.sent;
|
|
194
198
|
console.log(res2 === null || res2 === void 0 ? void 0 : res2.status, di2.tags);
|
|
195
|
-
case
|
|
199
|
+
case 56:
|
|
196
200
|
_context2.next = 7;
|
|
197
201
|
break;
|
|
198
|
-
case
|
|
199
|
-
_context2.next =
|
|
202
|
+
case 58:
|
|
203
|
+
_context2.next = 63;
|
|
200
204
|
break;
|
|
201
|
-
case
|
|
202
|
-
_context2.prev =
|
|
205
|
+
case 60:
|
|
206
|
+
_context2.prev = 60;
|
|
203
207
|
_context2.t3 = _context2["catch"](4);
|
|
204
208
|
console.log(_context2.t3);
|
|
205
|
-
case
|
|
209
|
+
case 63:
|
|
206
210
|
case "end":
|
|
207
211
|
return _context2.stop();
|
|
208
212
|
}
|
|
209
|
-
}, _callee2, null, [[4,
|
|
213
|
+
}, _callee2, null, [[4, 60], [29, 39]]);
|
|
210
214
|
}));
|
|
211
215
|
return function (_x, _x2) {
|
|
212
216
|
return _ref2.apply(this, arguments);
|
package/esm/bundler.js
CHANGED
|
@@ -31,80 +31,82 @@ const bundler = ({ port = 4001, jwk, timeout = 1000 * 60 } = {}) => {
|
|
|
31
31
|
const out = structured_to(httpsig_from(toMsg(req)))
|
|
32
32
|
for (const k in out.body?.commitments ?? {}) {
|
|
33
33
|
const msg = out.body?.commitments[k]
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const tags = []
|
|
42
|
-
let type = null
|
|
43
|
-
if (msg["original-tags"]) {
|
|
44
|
-
for (const tagObj of Object.values(msg["original-tags"])) {
|
|
45
|
-
tags.push({ name: tagObj.name, value: tagObj.value })
|
|
46
|
-
if (tagObj.name === "Type") {
|
|
47
|
-
type = tagObj.value
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
let opt = { tags }
|
|
52
|
-
if (type !== "Process") opt.target = out.process
|
|
53
|
-
const di = await createData(out.data || "", signer, opt)
|
|
54
|
-
await di.setSignature(msg.signature)
|
|
55
|
-
const res = await fetch("https://up.arweave.net:443/tx", {
|
|
56
|
-
method: "POST",
|
|
57
|
-
headers: {
|
|
58
|
-
"Content-Type": "application/octet-stream",
|
|
59
|
-
},
|
|
60
|
-
body: di.binary,
|
|
61
|
-
})
|
|
62
|
-
console.log(res?.status, di.tags)
|
|
63
|
-
const dis = [di]
|
|
64
|
-
if (type === "Message") {
|
|
65
|
-
if (!out["block-timestamp"]) {
|
|
66
|
-
try {
|
|
67
|
-
if (Date.now() - last_checked > timeout) {
|
|
68
|
-
const json = await fetch(
|
|
69
|
-
"https://arweave.net/block/current"
|
|
70
|
-
).then(r => r.json())
|
|
71
|
-
height = json.height
|
|
72
|
-
timestamp = json.timestamp
|
|
73
|
-
last_checked = Date.now()
|
|
74
|
-
}
|
|
75
|
-
} catch (e) {
|
|
76
|
-
console.log(e)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
const atags = {
|
|
80
|
-
Process: out.process,
|
|
81
|
-
Epoch: out.epoch,
|
|
82
|
-
Nonce: Number(++nonce).toString(),
|
|
83
|
-
"Hash-Chain": out["hash-chain"],
|
|
84
|
-
"Block-Height": Number(out["block-height"] ?? height).toString(),
|
|
85
|
-
Tmestamp: Number(out["block-timestamp"] ?? timestamp).toString(),
|
|
86
|
-
"Data-Protocol": "ao",
|
|
87
|
-
Slot: Number(out.slot).toString(),
|
|
88
|
-
Variant: "ao.WDB.1",
|
|
89
|
-
Type: "Assignment",
|
|
90
|
-
Message: di.id,
|
|
34
|
+
if (msg["commitment-device"] === "ans104@1.0") {
|
|
35
|
+
const signer = {
|
|
36
|
+
signatureType: 1,
|
|
37
|
+
signatureLength: 512,
|
|
38
|
+
ownerLength: 512,
|
|
39
|
+
publicKey: msg.owner,
|
|
40
|
+
sign: async () => {},
|
|
91
41
|
}
|
|
92
42
|
const tags = []
|
|
43
|
+
let type = null
|
|
93
44
|
if (msg["original-tags"]) {
|
|
94
|
-
for (const
|
|
45
|
+
for (const tagObj of Object.values(msg["original-tags"])) {
|
|
46
|
+
tags.push({ name: tagObj.name, value: tagObj.value })
|
|
47
|
+
if (tagObj.name === "Type") {
|
|
48
|
+
type = tagObj.value
|
|
49
|
+
}
|
|
50
|
+
}
|
|
95
51
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
await
|
|
99
|
-
|
|
100
|
-
const
|
|
52
|
+
let opt = { tags }
|
|
53
|
+
if (type !== "Process") opt.target = out.process
|
|
54
|
+
const di = await createData(out.data || "", signer, opt)
|
|
55
|
+
await di.setSignature(msg.signature)
|
|
56
|
+
const res = await fetch("https://up.arweave.net:443/tx", {
|
|
101
57
|
method: "POST",
|
|
102
58
|
headers: {
|
|
103
59
|
"Content-Type": "application/octet-stream",
|
|
104
60
|
},
|
|
105
|
-
body:
|
|
61
|
+
body: di.binary,
|
|
106
62
|
})
|
|
107
|
-
console.log(
|
|
63
|
+
console.log(res?.status, di.tags)
|
|
64
|
+
const dis = [di]
|
|
65
|
+
if (type === "Message") {
|
|
66
|
+
if (!out["block-timestamp"]) {
|
|
67
|
+
try {
|
|
68
|
+
if (Date.now() - last_checked > timeout) {
|
|
69
|
+
const json = await fetch(
|
|
70
|
+
"https://arweave.net/block/current"
|
|
71
|
+
).then(r => r.json())
|
|
72
|
+
height = json.height
|
|
73
|
+
timestamp = json.timestamp
|
|
74
|
+
last_checked = Date.now()
|
|
75
|
+
}
|
|
76
|
+
} catch (e) {
|
|
77
|
+
console.log(e)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const atags = {
|
|
81
|
+
Process: out.process,
|
|
82
|
+
Epoch: out.epoch,
|
|
83
|
+
Nonce: Number(++nonce).toString(),
|
|
84
|
+
"Hash-Chain": out["hash-chain"],
|
|
85
|
+
"Block-Height": Number(out["block-height"] ?? height).toString(),
|
|
86
|
+
Tmestamp: Number(out["block-timestamp"] ?? timestamp).toString(),
|
|
87
|
+
"Data-Protocol": "ao",
|
|
88
|
+
Slot: Number(out.slot).toString(),
|
|
89
|
+
Variant: "ao.WDB.1",
|
|
90
|
+
Type: "Assignment",
|
|
91
|
+
Message: di.id,
|
|
92
|
+
}
|
|
93
|
+
const tags = []
|
|
94
|
+
if (msg["original-tags"]) {
|
|
95
|
+
for (const k in atags) tags.push({ name: k, value: atags[k] })
|
|
96
|
+
}
|
|
97
|
+
const signer = new ArweaveSigner(jwk)
|
|
98
|
+
const di2 = await createData("", signer, { tags })
|
|
99
|
+
await di2.sign(signer)
|
|
100
|
+
dis.push(di2)
|
|
101
|
+
const res2 = await fetch("https://up.arweave.net:443/tx", {
|
|
102
|
+
method: "POST",
|
|
103
|
+
headers: {
|
|
104
|
+
"Content-Type": "application/octet-stream",
|
|
105
|
+
},
|
|
106
|
+
body: di2.binary,
|
|
107
|
+
})
|
|
108
|
+
console.log(res2?.status, di2.tags)
|
|
109
|
+
}
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
112
|
} catch (e) {
|