@btc-vision/btc-runtime 1.9.15 → 1.9.16
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 +1 -1
- package/runtime/contracts/OP20.ts +23 -27
package/package.json
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import { u256 } from '@btc-vision/as-bignum/assembly';
|
|
2
2
|
|
|
3
3
|
import { BytesWriter } from '../buffer/BytesWriter';
|
|
4
|
+
import {
|
|
5
|
+
ALLOWANCE_DECREASE_TYPE_HASH,
|
|
6
|
+
ALLOWANCE_INCREASE_TYPE_HASH,
|
|
7
|
+
ALLOWANCE_SELECTOR,
|
|
8
|
+
BALANCE_OF_SELECTOR,
|
|
9
|
+
DECIMALS_SELECTOR,
|
|
10
|
+
DOMAIN_SEPARATOR_SELECTOR,
|
|
11
|
+
ICON_SELECTOR,
|
|
12
|
+
MAXIMUM_SUPPLY_SELECTOR,
|
|
13
|
+
METADATA_SELECTOR,
|
|
14
|
+
NAME_SELECTOR,
|
|
15
|
+
NONCE_OF_SELECTOR,
|
|
16
|
+
ON_OP20_RECEIVED_SELECTOR,
|
|
17
|
+
OP712_DOMAIN_TYPE_HASH,
|
|
18
|
+
OP712_VERSION_HASH,
|
|
19
|
+
SYMBOL_SELECTOR,
|
|
20
|
+
TOTAL_SUPPLY_SELECTOR,
|
|
21
|
+
} from '../constants/Exports';
|
|
4
22
|
import { Blockchain } from '../env';
|
|
5
23
|
import { sha256, sha256String } from '../env/global';
|
|
6
24
|
import { ApprovedEvent, BurnedEvent, MintedEvent, TransferredEvent } from '../events/predefined';
|
|
25
|
+
import { Selector } from '../math/abi';
|
|
7
26
|
import { EMPTY_POINTER } from '../math/bytes';
|
|
8
27
|
import { AddressMemoryMap } from '../memory/AddressMemoryMap';
|
|
9
28
|
import { MapOfMap } from '../memory/MapOfMap';
|
|
@@ -23,26 +42,7 @@ import {
|
|
|
23
42
|
} from '../utils';
|
|
24
43
|
import { IOP20 } from './interfaces/IOP20';
|
|
25
44
|
import { OP20InitParameters } from './interfaces/OP20InitParameters';
|
|
26
|
-
import {
|
|
27
|
-
ALLOWANCE_DECREASE_TYPE_HASH,
|
|
28
|
-
ALLOWANCE_INCREASE_TYPE_HASH,
|
|
29
|
-
ALLOWANCE_SELECTOR,
|
|
30
|
-
BALANCE_OF_SELECTOR,
|
|
31
|
-
DECIMALS_SELECTOR,
|
|
32
|
-
DOMAIN_SEPARATOR_SELECTOR,
|
|
33
|
-
ICON_SELECTOR,
|
|
34
|
-
MAXIMUM_SUPPLY_SELECTOR,
|
|
35
|
-
METADATA_SELECTOR,
|
|
36
|
-
NAME_SELECTOR,
|
|
37
|
-
NONCE_OF_SELECTOR,
|
|
38
|
-
ON_OP20_RECEIVED_SELECTOR,
|
|
39
|
-
OP712_DOMAIN_TYPE_HASH,
|
|
40
|
-
OP712_VERSION_HASH,
|
|
41
|
-
SYMBOL_SELECTOR,
|
|
42
|
-
TOTAL_SUPPLY_SELECTOR,
|
|
43
|
-
} from '../constants/Exports';
|
|
44
45
|
import { ReentrancyGuard, ReentrancyLevel } from './ReentrancyGuard';
|
|
45
|
-
import { Selector } from '../math/abi';
|
|
46
46
|
|
|
47
47
|
const nonceMapPointer: u16 = Blockchain.nextPointer;
|
|
48
48
|
const maxSupplyPointer: u16 = Blockchain.nextPointer;
|
|
@@ -127,7 +127,7 @@ export abstract class OP20 extends ReentrancyGuard implements IOP20 {
|
|
|
127
127
|
@returns({ name: 'decimals', type: ABIDataTypes.UINT8 })
|
|
128
128
|
public decimals(_: Calldata): BytesWriter {
|
|
129
129
|
const w = new BytesWriter(1);
|
|
130
|
-
w.writeU8(this._decimals.value.toU32());
|
|
130
|
+
w.writeU8(<u8>this._decimals.value.toU32());
|
|
131
131
|
return w;
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -191,11 +191,7 @@ export abstract class OP20 extends ReentrancyGuard implements IOP20 {
|
|
|
191
191
|
)
|
|
192
192
|
@emit('Transferred')
|
|
193
193
|
public transfer(calldata: Calldata): BytesWriter {
|
|
194
|
-
this._transfer(
|
|
195
|
-
Blockchain.tx.sender,
|
|
196
|
-
calldata.readAddress(),
|
|
197
|
-
calldata.readU256(),
|
|
198
|
-
);
|
|
194
|
+
this._transfer(Blockchain.tx.sender, calldata.readAddress(), calldata.readU256());
|
|
199
195
|
return new BytesWriter(0);
|
|
200
196
|
}
|
|
201
197
|
|
|
@@ -356,7 +352,7 @@ export abstract class OP20 extends ReentrancyGuard implements IOP20 {
|
|
|
356
352
|
w.writeStringWithLength(name);
|
|
357
353
|
w.writeStringWithLength(symbol);
|
|
358
354
|
w.writeStringWithLength(icon);
|
|
359
|
-
w.writeU8(this._decimals.value.toU32());
|
|
355
|
+
w.writeU8(<u8>this._decimals.value.toU32());
|
|
360
356
|
w.writeU256(this._totalSupply.value);
|
|
361
357
|
w.writeBytesWithLength(domainSeparator);
|
|
362
358
|
|
|
@@ -396,7 +392,7 @@ export abstract class OP20 extends ReentrancyGuard implements IOP20 {
|
|
|
396
392
|
}
|
|
397
393
|
|
|
398
394
|
protected _safeTransfer(from: Address, to: Address, amount: u256, data: Uint8Array): void {
|
|
399
|
-
this._transfer(from,
|
|
395
|
+
this._transfer(from, to, amount);
|
|
400
396
|
|
|
401
397
|
if (Blockchain.isContract(to)) {
|
|
402
398
|
// In CALLBACK mode, the guard allows depth up to 1
|