@btc-vision/btc-runtime 1.6.3 → 1.7.0
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/README.md
CHANGED
|
@@ -132,9 +132,9 @@ export class MyToken extends DeployableOP_20 {
|
|
|
132
132
|
|
|
133
133
|
public override execute(method: Selector, calldata: Calldata): BytesWriter {
|
|
134
134
|
switch (method) {
|
|
135
|
-
case encodeSelector('airdrop'):
|
|
135
|
+
case encodeSelector('airdrop()'):
|
|
136
136
|
return this.airdrop(calldata);
|
|
137
|
-
case encodeSelector('airdropWithAmount'):
|
|
137
|
+
case encodeSelector('airdropWithAmount()'):
|
|
138
138
|
return this.airdropWithAmount(calldata);
|
|
139
139
|
default:
|
|
140
140
|
return super.execute(method, calldata);
|
package/package.json
CHANGED
|
@@ -206,7 +206,7 @@ export class BytesReader {
|
|
|
206
206
|
* Reads a string of `length` raw bytes, zeroStop = true for convenience.
|
|
207
207
|
* (Or the writer may not have used zeroStop.)
|
|
208
208
|
*/
|
|
209
|
-
public readString(length:
|
|
209
|
+
public readString(length: u32): string {
|
|
210
210
|
const bytes = this.readBytes(length, true);
|
|
211
211
|
return String.UTF8.decode(bytes.buffer);
|
|
212
212
|
}
|
|
@@ -216,7 +216,7 @@ export class BytesReader {
|
|
|
216
216
|
* The AS writer calls `writeStringWithLength(value: string)` => writes length big-endian by default.
|
|
217
217
|
*/
|
|
218
218
|
public readStringWithLength(be: boolean = true): string {
|
|
219
|
-
const length = this.
|
|
219
|
+
const length = this.readU32(be);
|
|
220
220
|
return this.readString(length);
|
|
221
221
|
}
|
|
222
222
|
|
|
@@ -286,7 +286,7 @@ export class BytesWriter {
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
public writeStringWithLength(value: string): void {
|
|
289
|
-
this.
|
|
289
|
+
this.writeU32(u32(value.length));
|
|
290
290
|
this.writeString(value);
|
|
291
291
|
}
|
|
292
292
|
|
|
@@ -352,8 +352,8 @@ export class BytesWriter {
|
|
|
352
352
|
private resize(size: u32): void {
|
|
353
353
|
throw new Revert(
|
|
354
354
|
`Buffer is getting resized. This is bad for performance. ` +
|
|
355
|
-
|
|
356
|
-
|
|
355
|
+
`Expected size: ${this.buffer.byteLength + size} - ` +
|
|
356
|
+
`Current size: ${this.buffer.byteLength}`,
|
|
357
357
|
);
|
|
358
358
|
}
|
|
359
359
|
}
|
|
@@ -205,23 +205,23 @@ export abstract class DeployableOP_20 extends OP_NET implements IOP_20 {
|
|
|
205
205
|
let response: BytesWriter;
|
|
206
206
|
|
|
207
207
|
switch (method) {
|
|
208
|
-
case encodeSelector('decimals'):
|
|
208
|
+
case encodeSelector('decimals()'):
|
|
209
209
|
response = new BytesWriter(BOOLEAN_BYTE_LENGTH);
|
|
210
210
|
response.writeU8(this.decimals);
|
|
211
211
|
break;
|
|
212
|
-
case encodeSelector('name'):
|
|
212
|
+
case encodeSelector('name()'):
|
|
213
213
|
response = new BytesWriter(this.name.length + 2);
|
|
214
214
|
response.writeStringWithLength(this.name);
|
|
215
215
|
break;
|
|
216
|
-
case encodeSelector('symbol'):
|
|
216
|
+
case encodeSelector('symbol()'):
|
|
217
217
|
response = new BytesWriter(this.symbol.length + 2);
|
|
218
218
|
response.writeStringWithLength(this.symbol);
|
|
219
219
|
break;
|
|
220
|
-
case encodeSelector('totalSupply'):
|
|
220
|
+
case encodeSelector('totalSupply()'):
|
|
221
221
|
response = new BytesWriter(U256_BYTE_LENGTH);
|
|
222
222
|
response.writeU256(this.totalSupply);
|
|
223
223
|
break;
|
|
224
|
-
case encodeSelector('maximumSupply'):
|
|
224
|
+
case encodeSelector('maximumSupply()'):
|
|
225
225
|
response = new BytesWriter(U256_BYTE_LENGTH);
|
|
226
226
|
response.writeU256(this.maxSupply);
|
|
227
227
|
break;
|
|
@@ -27,7 +27,7 @@ export class OP_NET implements IBTC {
|
|
|
27
27
|
let response: BytesWriter;
|
|
28
28
|
|
|
29
29
|
switch (method) {
|
|
30
|
-
case encodeSelector('deployer'):
|
|
30
|
+
case encodeSelector('deployer()'):
|
|
31
31
|
response = new BytesWriter(ADDRESS_BYTE_LENGTH);
|
|
32
32
|
response.writeAddress(this.contractDeployer);
|
|
33
33
|
break;
|