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.
@@ -161,10 +161,10 @@ export class TokenMintRequest {
161
161
  }
162
162
 
163
163
  export class OpReturnData {
164
- buffer: Buffer;
164
+ buffer: Uint8Array;
165
165
 
166
- public constructor(buffer: Buffer) {
167
- this.buffer = Buffer.from(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 | Buffer | Uint8Array) {
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(Buffer.from(uint8Array));
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 Buffer or UTF-8 encoded string messages to be converted to OP_RETURN data
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 | Buffer | Uint8Array>) {
230
- let data: Buffer = Buffer.from([0x6a]); // OP_RETURN
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 | Buffer;
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 = Buffer.from(element);
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 = Buffer.from([...data, ...lengthData, ...elementData]);
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 | Buffer>;
297
+ export type SendRequestArray = Array<string | number | UnitEnum | Uint8Array>;
316
298
 
317
299
  export type SourceOutput = Input & Output;
318
300
 
@@ -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