@btc-vision/btc-runtime 1.9.6 → 1.9.8
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
|
@@ -33,10 +33,7 @@ import {
|
|
|
33
33
|
OP721_TRANSFER_TYPE_HASH,
|
|
34
34
|
} from '../constants/Exports';
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
const namePointer: u16 = Blockchain.nextPointer;
|
|
38
|
-
const symbolPointer: u16 = Blockchain.nextPointer;
|
|
39
|
-
const baseURIPointer: u16 = Blockchain.nextPointer;
|
|
36
|
+
const stringPointer: u16 = Blockchain.nextPointer;
|
|
40
37
|
const totalSupplyPointer: u16 = Blockchain.nextPointer;
|
|
41
38
|
const maxSupplyPointer: u16 = Blockchain.nextPointer;
|
|
42
39
|
const ownerOfMapPointer: u16 = Blockchain.nextPointer;
|
|
@@ -56,6 +53,11 @@ export abstract class OP721 extends ReentrancyGuard implements IOP721 {
|
|
|
56
53
|
protected readonly _name: StoredString;
|
|
57
54
|
protected readonly _symbol: StoredString;
|
|
58
55
|
protected readonly _baseURI: StoredString;
|
|
56
|
+
protected readonly _collectionBanner: StoredString;
|
|
57
|
+
protected readonly _collectionIcon: StoredString;
|
|
58
|
+
protected readonly _collectionDescription: StoredString;
|
|
59
|
+
protected readonly _collectionWebsite: StoredString;
|
|
60
|
+
|
|
59
61
|
protected readonly _totalSupply: StoredU256;
|
|
60
62
|
protected readonly _maxSupply: StoredU256;
|
|
61
63
|
protected readonly _nextTokenId: StoredU256;
|
|
@@ -84,9 +86,14 @@ export abstract class OP721 extends ReentrancyGuard implements IOP721 {
|
|
|
84
86
|
public constructor() {
|
|
85
87
|
super();
|
|
86
88
|
|
|
87
|
-
this._name = new StoredString(
|
|
88
|
-
this._symbol = new StoredString(
|
|
89
|
-
this._baseURI = new StoredString(
|
|
89
|
+
this._name = new StoredString(stringPointer, 0);
|
|
90
|
+
this._symbol = new StoredString(stringPointer, 2);
|
|
91
|
+
this._baseURI = new StoredString(stringPointer, 3);
|
|
92
|
+
this._collectionBanner = new StoredString(stringPointer, 4);
|
|
93
|
+
this._collectionIcon = new StoredString(stringPointer, 5);
|
|
94
|
+
this._collectionDescription = new StoredString(stringPointer, 6);
|
|
95
|
+
this._collectionWebsite = new StoredString(stringPointer, 7);
|
|
96
|
+
|
|
90
97
|
this._totalSupply = new StoredU256(totalSupplyPointer, EMPTY_POINTER);
|
|
91
98
|
this._maxSupply = new StoredU256(maxSupplyPointer, EMPTY_POINTER);
|
|
92
99
|
this._nextTokenId = new StoredU256(nextTokenIdPointer, EMPTY_POINTER);
|
|
@@ -126,6 +133,22 @@ export abstract class OP721 extends ReentrancyGuard implements IOP721 {
|
|
|
126
133
|
return this._maxSupply.value;
|
|
127
134
|
}
|
|
128
135
|
|
|
136
|
+
public get collectionBanner(): string {
|
|
137
|
+
return this._collectionBanner.value;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public get collectionIcon(): string {
|
|
141
|
+
return this._collectionIcon.value;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public get collectionDescription(): string {
|
|
145
|
+
return this._collectionDescription.value;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
public get collectionWebsite(): string {
|
|
149
|
+
return this._collectionWebsite.value;
|
|
150
|
+
}
|
|
151
|
+
|
|
129
152
|
public instantiate(
|
|
130
153
|
params: OP721InitParameters,
|
|
131
154
|
skipDeployerVerification: boolean = false,
|
|
@@ -144,6 +167,11 @@ export abstract class OP721 extends ReentrancyGuard implements IOP721 {
|
|
|
144
167
|
this._nextTokenId.value = u256.One;
|
|
145
168
|
this._initialized.value = u256.One;
|
|
146
169
|
this._tokenURICounter.value = u256.Zero;
|
|
170
|
+
|
|
171
|
+
this._collectionBanner.value = params.collectionBanner;
|
|
172
|
+
this._collectionIcon.value = params.collectionIcon;
|
|
173
|
+
this._collectionDescription.value = params.collectionDescription;
|
|
174
|
+
this._collectionWebsite.value = params.collectionWebsite;
|
|
147
175
|
}
|
|
148
176
|
|
|
149
177
|
@method('name')
|
|
@@ -172,6 +200,28 @@ export abstract class OP721 extends ReentrancyGuard implements IOP721 {
|
|
|
172
200
|
return w;
|
|
173
201
|
}
|
|
174
202
|
|
|
203
|
+
@method('collectionInfo')
|
|
204
|
+
@returns(
|
|
205
|
+
{ name: 'icon', type: ABIDataTypes.STRING },
|
|
206
|
+
{ name: 'banner', type: ABIDataTypes.STRING },
|
|
207
|
+
{ name: 'description', type: ABIDataTypes.STRING },
|
|
208
|
+
{ name: 'website', type: ABIDataTypes.STRING },
|
|
209
|
+
)
|
|
210
|
+
public collectionInfo(_: Calldata): BytesWriter {
|
|
211
|
+
const length =
|
|
212
|
+
String.UTF8.byteLength(this.collectionIcon) +
|
|
213
|
+
String.UTF8.byteLength(this.collectionDescription) +
|
|
214
|
+
String.UTF8.byteLength(this.collectionWebsite) +
|
|
215
|
+
String.UTF8.byteLength(this.collectionBanner);
|
|
216
|
+
|
|
217
|
+
const w = new BytesWriter(U32_BYTE_LENGTH * 4 + length);
|
|
218
|
+
w.writeStringWithLength(this.collectionIcon);
|
|
219
|
+
w.writeStringWithLength(this.collectionBanner);
|
|
220
|
+
w.writeStringWithLength(this.collectionDescription);
|
|
221
|
+
w.writeStringWithLength(this.collectionWebsite);
|
|
222
|
+
return w;
|
|
223
|
+
}
|
|
224
|
+
|
|
175
225
|
@method({ name: 'tokenId', type: ABIDataTypes.UINT256 })
|
|
176
226
|
@returns({ name: 'uri', type: ABIDataTypes.STRING })
|
|
177
227
|
public tokenURI(calldata: Calldata): BytesWriter {
|
|
@@ -459,6 +509,60 @@ export abstract class OP721 extends ReentrancyGuard implements IOP721 {
|
|
|
459
509
|
return new BytesWriter(0);
|
|
460
510
|
}
|
|
461
511
|
|
|
512
|
+
@method()
|
|
513
|
+
@returns(
|
|
514
|
+
{ name: 'name', type: ABIDataTypes.STRING },
|
|
515
|
+
{ name: 'symbol', type: ABIDataTypes.STRING },
|
|
516
|
+
{ name: 'icon', type: ABIDataTypes.STRING },
|
|
517
|
+
{ name: 'banner', type: ABIDataTypes.STRING },
|
|
518
|
+
{ name: 'description', type: ABIDataTypes.STRING },
|
|
519
|
+
{ name: 'website', type: ABIDataTypes.STRING },
|
|
520
|
+
{ name: 'totalSupply', type: ABIDataTypes.UINT256 },
|
|
521
|
+
{ name: 'maximumSupply', type: ABIDataTypes.UINT256 },
|
|
522
|
+
{ name: 'domainSeparator', type: ABIDataTypes.BYTES32 },
|
|
523
|
+
)
|
|
524
|
+
public metadata(_: Calldata): BytesWriter {
|
|
525
|
+
const name = this.name;
|
|
526
|
+
const symbol = this.symbol;
|
|
527
|
+
const icon = this.collectionIcon;
|
|
528
|
+
const banner = this.collectionBanner;
|
|
529
|
+
const description = this.collectionDescription;
|
|
530
|
+
const website = this.collectionWebsite;
|
|
531
|
+
const domainSeparator = this._buildDomainSeparator();
|
|
532
|
+
|
|
533
|
+
const nameLength = String.UTF8.byteLength(name);
|
|
534
|
+
const symbolLength = String.UTF8.byteLength(symbol);
|
|
535
|
+
const iconLength = String.UTF8.byteLength(icon);
|
|
536
|
+
const bannerLength = String.UTF8.byteLength(banner);
|
|
537
|
+
const descriptionLength = String.UTF8.byteLength(description);
|
|
538
|
+
const websiteLength = String.UTF8.byteLength(website);
|
|
539
|
+
|
|
540
|
+
const totalSize =
|
|
541
|
+
U32_BYTE_LENGTH * 6 +
|
|
542
|
+
nameLength +
|
|
543
|
+
symbolLength +
|
|
544
|
+
iconLength +
|
|
545
|
+
bannerLength +
|
|
546
|
+
descriptionLength +
|
|
547
|
+
websiteLength +
|
|
548
|
+
U256_BYTE_LENGTH * 2 +
|
|
549
|
+
U32_BYTE_LENGTH +
|
|
550
|
+
domainSeparator.length;
|
|
551
|
+
|
|
552
|
+
const w = new BytesWriter(totalSize);
|
|
553
|
+
w.writeStringWithLength(name);
|
|
554
|
+
w.writeStringWithLength(symbol);
|
|
555
|
+
w.writeStringWithLength(icon);
|
|
556
|
+
w.writeStringWithLength(banner);
|
|
557
|
+
w.writeStringWithLength(description);
|
|
558
|
+
w.writeStringWithLength(website);
|
|
559
|
+
w.writeU256(this.totalSupply);
|
|
560
|
+
w.writeU256(this.maxSupply);
|
|
561
|
+
w.writeBytesWithLength(domainSeparator);
|
|
562
|
+
|
|
563
|
+
return w;
|
|
564
|
+
}
|
|
565
|
+
|
|
462
566
|
protected _mint(to: Address, tokenId: u256): void {
|
|
463
567
|
if (to === Address.zero() || to === Address.dead()) {
|
|
464
568
|
throw new Revert('Cannot mint to zero address');
|
|
@@ -613,7 +717,7 @@ export abstract class OP721 extends ReentrancyGuard implements IOP721 {
|
|
|
613
717
|
protected _setTokenURI(tokenId: u256, uri: string): void {
|
|
614
718
|
if (!this._exists(tokenId)) throw new Revert('Token does not exist');
|
|
615
719
|
|
|
616
|
-
if (uri.length > MAX_URI_LENGTH) {
|
|
720
|
+
if (<u32>uri.length > MAX_URI_LENGTH) {
|
|
617
721
|
throw new Revert('URI exceeds maximum length');
|
|
618
722
|
}
|
|
619
723
|
|
|
@@ -6,10 +6,29 @@ export class OP721InitParameters {
|
|
|
6
6
|
public baseURI: string;
|
|
7
7
|
public maxSupply: u256;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
public collectionBanner: string;
|
|
10
|
+
public collectionIcon: string;
|
|
11
|
+
public collectionWebsite: string;
|
|
12
|
+
public collectionDescription: string;
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
name: string,
|
|
16
|
+
symbol: string,
|
|
17
|
+
baseURI: string,
|
|
18
|
+
maxSupply: u256,
|
|
19
|
+
collectionBanner: string = '',
|
|
20
|
+
collectionIcon: string = '',
|
|
21
|
+
collectionWebsite: string = '',
|
|
22
|
+
collectionDescription: string = '',
|
|
23
|
+
) {
|
|
10
24
|
this.name = name;
|
|
11
25
|
this.symbol = symbol;
|
|
12
26
|
this.baseURI = baseURI;
|
|
13
27
|
this.maxSupply = maxSupply;
|
|
28
|
+
|
|
29
|
+
this.collectionBanner = collectionBanner;
|
|
30
|
+
this.collectionIcon = collectionIcon;
|
|
31
|
+
this.collectionWebsite = collectionWebsite;
|
|
32
|
+
this.collectionDescription = collectionDescription;
|
|
14
33
|
}
|
|
15
34
|
}
|
|
@@ -9,7 +9,7 @@ export const MAX_URI_LENGTH: u32 = 200;
|
|
|
9
9
|
@final
|
|
10
10
|
export class URIEvent extends NetEvent {
|
|
11
11
|
constructor(value: string, id: u256) {
|
|
12
|
-
const valueBytes:
|
|
12
|
+
const valueBytes: u32 = u32(String.UTF8.byteLength(value));
|
|
13
13
|
|
|
14
14
|
if (valueBytes > MAX_URI_LENGTH) {
|
|
15
15
|
throw new Revert('URI event exceeds max data size');
|