@btc-vision/btc-runtime 1.9.8 → 1.9.9
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/package.json
CHANGED
|
@@ -284,6 +284,15 @@ export class BytesReader {
|
|
|
284
284
|
return result;
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
+
public readU8Array(be: boolean = true): u8[] {
|
|
288
|
+
const length = this.readU16(be);
|
|
289
|
+
const result = new Array<u8>(length);
|
|
290
|
+
for (let i: u16 = 0; i < length; i++) {
|
|
291
|
+
result[i] = this.readU8();
|
|
292
|
+
}
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
|
|
287
296
|
public readU128Array(be: boolean = true): u128[] {
|
|
288
297
|
const length = this.readU16(be);
|
|
289
298
|
const result = new Array<u128>(length);
|
|
@@ -197,6 +197,16 @@ export class BytesWriter {
|
|
|
197
197
|
|
|
198
198
|
// ------------------ Array Writers ------------------ //
|
|
199
199
|
|
|
200
|
+
public writeU8Array(value: u8[], be: boolean = true): void {
|
|
201
|
+
if (value.length > 65535) throw new Revert('Array size is too large');
|
|
202
|
+
this.allocSafe(U16_BYTE_LENGTH + value.length);
|
|
203
|
+
this.writeU16(u16(value.length), be);
|
|
204
|
+
|
|
205
|
+
for (let i = 0; i < value.length; i++) {
|
|
206
|
+
this.writeU8(value[i]);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
200
210
|
public writeU16Array(value: u16[], be: boolean = true): void {
|
|
201
211
|
if (value.length > 65535) throw new Revert('Array size is too large');
|
|
202
212
|
this.allocSafe(U16_BYTE_LENGTH + value.length * U16_BYTE_LENGTH);
|
|
@@ -24,7 +24,13 @@ import { IOP721 } from './interfaces/IOP721';
|
|
|
24
24
|
import { OP721InitParameters } from './interfaces/OP721InitParameters';
|
|
25
25
|
import { ReentrancyGuard } from './ReentrancyGuard';
|
|
26
26
|
import { StoredMapU256 } from '../storage/maps/StoredMapU256';
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
ApprovedEvent,
|
|
29
|
+
ApprovedForAllEvent,
|
|
30
|
+
MAX_URI_LENGTH,
|
|
31
|
+
TransferredEvent,
|
|
32
|
+
URIEvent,
|
|
33
|
+
} from '../events/predefined';
|
|
28
34
|
import {
|
|
29
35
|
ON_OP721_RECEIVED_SELECTOR,
|
|
30
36
|
OP712_DOMAIN_TYPE_HASH,
|
|
@@ -251,6 +257,28 @@ export abstract class OP721 extends ReentrancyGuard implements IOP721 {
|
|
|
251
257
|
return w;
|
|
252
258
|
}
|
|
253
259
|
|
|
260
|
+
@method('changeMetadata')
|
|
261
|
+
public changeMetadata(calldata: Calldata): BytesWriter {
|
|
262
|
+
this.onlyDeployer(Blockchain.tx.sender);
|
|
263
|
+
|
|
264
|
+
const icon: string = calldata.readStringWithLength();
|
|
265
|
+
const banner: string = calldata.readStringWithLength();
|
|
266
|
+
const description: string = calldata.readStringWithLength();
|
|
267
|
+
const website: string = calldata.readStringWithLength();
|
|
268
|
+
|
|
269
|
+
if (icon.length == 0) throw new Revert('Icon cannot be empty');
|
|
270
|
+
if (banner.length == 0) throw new Revert('Banner cannot be empty');
|
|
271
|
+
if (description.length == 0) throw new Revert('Description cannot be empty');
|
|
272
|
+
if (website.length == 0) throw new Revert('Website cannot be empty');
|
|
273
|
+
|
|
274
|
+
this._collectionIcon.value = icon;
|
|
275
|
+
this._collectionBanner.value = banner;
|
|
276
|
+
this._collectionDescription.value = description;
|
|
277
|
+
this._collectionWebsite.value = website;
|
|
278
|
+
|
|
279
|
+
return new BytesWriter(0);
|
|
280
|
+
}
|
|
281
|
+
|
|
254
282
|
@method('totalSupply')
|
|
255
283
|
@returns({ name: 'totalSupply', type: ABIDataTypes.UINT256 })
|
|
256
284
|
public fn_totalSupply(_: Calldata): BytesWriter {
|