mainnet-js 2.5.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.html +1 -1
- package/dist/{mainnet-2.5.0.js → mainnet-2.6.1.js} +7 -37
- package/dist/module/network/constant.js +2 -2
- package/dist/module/network/constant.js.map +1 -1
- package/dist/module/util/asSendRequestObject.d.ts.map +1 -1
- package/dist/module/util/asSendRequestObject.js +4 -4
- package/dist/module/util/asSendRequestObject.js.map +1 -1
- package/dist/module/util/header.d.ts.map +1 -1
- package/dist/module/util/header.js +8 -7
- package/dist/module/util/header.js.map +1 -1
- package/dist/module/wallet/model.d.ts +6 -15
- package/dist/module/wallet/model.d.ts.map +1 -1
- package/dist/module/wallet/model.js +6 -24
- package/dist/module/wallet/model.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/polyfill/support/types.js +0 -4
- package/src/network/constant.ts +2 -2
- package/src/util/asSendRequestObject.ts +8 -6
- package/src/util/header.ts +17 -7
- package/src/wallet/Wif.test.ts +2 -2
- package/src/wallet/model.ts +12 -30
- package/webpack.config.cjs +0 -3
package/src/wallet/model.ts
CHANGED
|
@@ -161,10 +161,10 @@ export class TokenMintRequest {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
export class OpReturnData {
|
|
164
|
-
buffer:
|
|
164
|
+
buffer: Uint8Array;
|
|
165
165
|
|
|
166
|
-
public constructor(buffer:
|
|
167
|
-
this.buffer =
|
|
166
|
+
public constructor(buffer: Uint8Array) {
|
|
167
|
+
this.buffer = Uint8Array.from(buffer);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
/**
|
|
@@ -174,7 +174,7 @@ export class OpReturnData {
|
|
|
174
174
|
*
|
|
175
175
|
* @returns class instance
|
|
176
176
|
*/
|
|
177
|
-
public static from(data: string |
|
|
177
|
+
public static from(data: string | Uint8Array) {
|
|
178
178
|
return this.fromArray([data]);
|
|
179
179
|
}
|
|
180
180
|
|
|
@@ -189,21 +189,6 @@ export class OpReturnData {
|
|
|
189
189
|
return this.fromArray([string]);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
/**
|
|
193
|
-
* buffer - Accept OP_RETURN data as a binary buffer.
|
|
194
|
-
* If buffer lacks the OP_RETURN and OP_PUSHDATA opcodes, they will be prepended.
|
|
195
|
-
*
|
|
196
|
-
* @param buffer Data buffer to be assigned to the OP_RETURN outpit
|
|
197
|
-
*
|
|
198
|
-
* @returns class instance
|
|
199
|
-
*/
|
|
200
|
-
public static fromBuffer(buffer: Buffer) {
|
|
201
|
-
if (buffer[0] !== 0x6a) {
|
|
202
|
-
return this.fromArray([buffer]);
|
|
203
|
-
}
|
|
204
|
-
return new this(buffer);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
192
|
/**
|
|
208
193
|
* buffer - Accept OP_RETURN data as a binary buffer.
|
|
209
194
|
* If buffer lacks the OP_RETURN and OP_PUSHDATA opcodes, they will be prepended.
|
|
@@ -216,30 +201,27 @@ export class OpReturnData {
|
|
|
216
201
|
if (uint8Array[0] !== 0x6a) {
|
|
217
202
|
return this.fromArray([uint8Array]);
|
|
218
203
|
}
|
|
219
|
-
return new this(
|
|
204
|
+
return new this(Uint8Array.from(uint8Array));
|
|
220
205
|
}
|
|
221
206
|
|
|
222
207
|
/**
|
|
223
208
|
* fromArray - Accept array of data
|
|
224
209
|
*
|
|
225
|
-
* @param array Array of
|
|
210
|
+
* @param array Array of Uint8Array or UTF-8 encoded string messages to be converted to OP_RETURN data
|
|
226
211
|
*
|
|
227
212
|
* @returns class instance
|
|
228
213
|
*/
|
|
229
|
-
public static fromArray(array: Array<string |
|
|
230
|
-
let data:
|
|
214
|
+
public static fromArray(array: Array<string | Uint8Array>) {
|
|
215
|
+
let data: Uint8Array = Uint8Array.from([0x6a]); // OP_RETURN
|
|
231
216
|
for (const element of array) {
|
|
232
217
|
let length: number;
|
|
233
|
-
let elementData: Uint8Array
|
|
218
|
+
let elementData: Uint8Array;
|
|
234
219
|
let lengthData: any;
|
|
235
220
|
if (typeof element === "string") {
|
|
236
221
|
elementData = utf8ToBin(element);
|
|
237
222
|
length = elementData.length;
|
|
238
|
-
} else if (element instanceof Buffer) {
|
|
239
|
-
elementData = element;
|
|
240
|
-
length = elementData.length;
|
|
241
223
|
} else if (element instanceof Uint8Array) {
|
|
242
|
-
elementData =
|
|
224
|
+
elementData = element;
|
|
243
225
|
length = elementData.length;
|
|
244
226
|
} else {
|
|
245
227
|
throw new Error("Wrong data array element");
|
|
@@ -255,7 +237,7 @@ export class OpReturnData {
|
|
|
255
237
|
throw new Error("OP_RETURN data can not exceed 220 bytes in size");
|
|
256
238
|
}
|
|
257
239
|
|
|
258
|
-
data =
|
|
240
|
+
data = Uint8Array.from([...data, ...lengthData, ...elementData]);
|
|
259
241
|
}
|
|
260
242
|
|
|
261
243
|
if (data.length > 220) {
|
|
@@ -312,7 +294,7 @@ export class OpReturnData {
|
|
|
312
294
|
}
|
|
313
295
|
}
|
|
314
296
|
|
|
315
|
-
export type SendRequestArray = Array<string | number | UnitEnum |
|
|
297
|
+
export type SendRequestArray = Array<string | number | UnitEnum | Uint8Array>;
|
|
316
298
|
|
|
317
299
|
export type SourceOutput = Input & Output;
|
|
318
300
|
|
package/webpack.config.cjs
CHANGED
|
@@ -74,9 +74,6 @@ const browserConfig = {
|
|
|
74
74
|
content:
|
|
75
75
|
'<script>document.addEventListener("DOMContentLoaded", async (event) => Object.assign(globalThis, await __mainnetPromise))</script>',
|
|
76
76
|
}),
|
|
77
|
-
new webpack.ProvidePlugin({
|
|
78
|
-
Buffer: ["buffer", "Buffer"],
|
|
79
|
-
}),
|
|
80
77
|
new CircularDependencyPlugin({
|
|
81
78
|
include: /src/,
|
|
82
79
|
// exclude detection of files based on a RegExp
|