@btc-vision/btc-runtime 1.0.29 → 1.0.30
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/buffer/BytesReader.ts +200 -200
- package/runtime/buffer/BytesWriter.ts +346 -346
- package/runtime/contracts/OP_20.ts +341 -341
- package/runtime/contracts/OP_NET.ts +73 -73
- package/runtime/contracts/interfaces/IOP_20.ts +21 -21
- package/runtime/env/BTCEnvironment.ts +319 -314
- package/runtime/env/index.ts +3 -3
- package/runtime/events/NetEvent.ts +27 -27
- package/runtime/events/predefined/ApproveEvent.ts +16 -16
- package/runtime/events/predefined/BurnEvent.ts +13 -13
- package/runtime/events/predefined/ClaimEvent.ts +13 -13
- package/runtime/events/predefined/MintEvent.ts +15 -15
- package/runtime/events/predefined/StakeEvent.ts +13 -13
- package/runtime/events/predefined/TransferEvent.ts +16 -16
- package/runtime/events/predefined/UnstakeEvent.ts +13 -13
- package/runtime/events/predefined/index.ts +7 -7
- package/runtime/exports/index.ts +37 -37
- package/runtime/generic/Map.ts +65 -65
- package/runtime/generic/MapU256.ts +57 -57
- package/runtime/index.ts +53 -52
- package/runtime/interfaces/DeployContractResponse.ts +12 -12
- package/runtime/interfaces/IBTC.ts +6 -6
- package/runtime/lang/Definitions.ts +1 -1
- package/runtime/math/abi.ts +37 -37
- package/runtime/math/bytes.ts +34 -34
- package/runtime/math/cyrb53.ts +46 -46
- package/runtime/math/rnd.ts +51 -51
- package/runtime/math/sha256.ts +12 -12
- package/runtime/memory/AddressMemoryMap.ts +44 -44
- package/runtime/memory/KeyMerger.ts +53 -53
- package/runtime/memory/MemorySlot.ts +1 -1
- package/runtime/memory/MemorySlotPointer.ts +3 -3
- package/runtime/memory/MultiAddressMemoryMap.ts +62 -62
- package/runtime/shared-libraries/TransferHelper.ts +64 -64
- package/runtime/storage/Serializable.ts +75 -0
- package/runtime/storage/StoredString.ts +145 -145
- package/runtime/storage/StoredU256.ts +246 -246
- package/runtime/types/Address.ts +5 -5
- package/runtime/types/Revert.ts +5 -5
- package/runtime/types/SafeMath.ts +197 -197
- package/runtime/types/index.ts +8 -8
- package/runtime/universal/ABIRegistry.ts +72 -72
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import { IBTC } from '../interfaces/IBTC';
|
|
2
|
-
import { Address } from '../types/Address';
|
|
3
|
-
import { Blockchain } from '../env';
|
|
4
|
-
import { Calldata } from '../universal/ABIRegistry';
|
|
5
|
-
import { BytesWriter } from '../buffer/BytesWriter';
|
|
6
|
-
import { encodeSelector, Selector } from '../math/abi';
|
|
7
|
-
import { Revert } from '../types/Revert';
|
|
8
|
-
import { MAX_EVENT_DATA_SIZE, NetEvent } from '../events/NetEvent';
|
|
9
|
-
|
|
10
|
-
export class OP_NET implements IBTC {
|
|
11
|
-
constructor() {}
|
|
12
|
-
|
|
13
|
-
public get address(): string {
|
|
14
|
-
return Blockchain.contractAddress;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public get owner(): string {
|
|
18
|
-
return Blockchain.owner;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public callMethod(method: Selector, calldata: Calldata): BytesWriter {
|
|
22
|
-
switch (method) {
|
|
23
|
-
case encodeSelector('isAddressOwner'):
|
|
24
|
-
return this.isAddressOwner(calldata);
|
|
25
|
-
default:
|
|
26
|
-
throw new Revert('Method not found');
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public callView(method: Selector): BytesWriter {
|
|
31
|
-
const response = new BytesWriter();
|
|
32
|
-
|
|
33
|
-
switch (method) {
|
|
34
|
-
case encodeSelector('address'):
|
|
35
|
-
response.writeAddress(this.address);
|
|
36
|
-
break;
|
|
37
|
-
case encodeSelector('owner'):
|
|
38
|
-
response.writeAddress(this.owner);
|
|
39
|
-
break;
|
|
40
|
-
default:
|
|
41
|
-
throw new Revert('Method not found');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return response;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
protected emitEvent(event: NetEvent): void {
|
|
48
|
-
if (event.length > MAX_EVENT_DATA_SIZE) {
|
|
49
|
-
throw new Error('Event data length exceeds maximum length.');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
Blockchain.addEvent(event);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
protected isSelf(address: Address): boolean {
|
|
56
|
-
return this.address === address;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
protected onlyOwner(caller: Address): void {
|
|
60
|
-
if (this.owner !== caller) {
|
|
61
|
-
throw new Revert('Only owner can call this method');
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
private isAddressOwner(calldata: Calldata): BytesWriter {
|
|
66
|
-
const response = new BytesWriter();
|
|
67
|
-
const owner = calldata.readAddress();
|
|
68
|
-
|
|
69
|
-
response.writeBoolean(this.owner === owner);
|
|
70
|
-
|
|
71
|
-
return response;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
1
|
+
import { IBTC } from '../interfaces/IBTC';
|
|
2
|
+
import { Address } from '../types/Address';
|
|
3
|
+
import { Blockchain } from '../env';
|
|
4
|
+
import { Calldata } from '../universal/ABIRegistry';
|
|
5
|
+
import { BytesWriter } from '../buffer/BytesWriter';
|
|
6
|
+
import { encodeSelector, Selector } from '../math/abi';
|
|
7
|
+
import { Revert } from '../types/Revert';
|
|
8
|
+
import { MAX_EVENT_DATA_SIZE, NetEvent } from '../events/NetEvent';
|
|
9
|
+
|
|
10
|
+
export class OP_NET implements IBTC {
|
|
11
|
+
constructor() {}
|
|
12
|
+
|
|
13
|
+
public get address(): string {
|
|
14
|
+
return Blockchain.contractAddress;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public get owner(): string {
|
|
18
|
+
return Blockchain.owner;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public callMethod(method: Selector, calldata: Calldata): BytesWriter {
|
|
22
|
+
switch (method) {
|
|
23
|
+
case encodeSelector('isAddressOwner'):
|
|
24
|
+
return this.isAddressOwner(calldata);
|
|
25
|
+
default:
|
|
26
|
+
throw new Revert('Method not found');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public callView(method: Selector): BytesWriter {
|
|
31
|
+
const response = new BytesWriter();
|
|
32
|
+
|
|
33
|
+
switch (method) {
|
|
34
|
+
case encodeSelector('address'):
|
|
35
|
+
response.writeAddress(this.address);
|
|
36
|
+
break;
|
|
37
|
+
case encodeSelector('owner'):
|
|
38
|
+
response.writeAddress(this.owner);
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
throw new Revert('Method not found');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return response;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
protected emitEvent(event: NetEvent): void {
|
|
48
|
+
if (event.length > MAX_EVENT_DATA_SIZE) {
|
|
49
|
+
throw new Error('Event data length exceeds maximum length.');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
Blockchain.addEvent(event);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
protected isSelf(address: Address): boolean {
|
|
56
|
+
return this.address === address;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
protected onlyOwner(caller: Address): void {
|
|
60
|
+
if (this.owner !== caller) {
|
|
61
|
+
throw new Revert('Only owner can call this method');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private isAddressOwner(calldata: Calldata): BytesWriter {
|
|
66
|
+
const response = new BytesWriter();
|
|
67
|
+
const owner = calldata.readAddress();
|
|
68
|
+
|
|
69
|
+
response.writeBoolean(this.owner === owner);
|
|
70
|
+
|
|
71
|
+
return response;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { BytesWriter } from '../../buffer/BytesWriter';
|
|
2
|
-
import { Calldata } from '../../universal/ABIRegistry';
|
|
3
|
-
import { StoredU256 } from '../../storage/StoredU256';
|
|
4
|
-
|
|
5
|
-
export interface IOP_20 {
|
|
6
|
-
readonly _totalSupply: StoredU256;
|
|
7
|
-
|
|
8
|
-
balanceOf(callData: Calldata): BytesWriter;
|
|
9
|
-
|
|
10
|
-
transfer(callData: Calldata): BytesWriter;
|
|
11
|
-
|
|
12
|
-
transferFrom(callData: Calldata): BytesWriter;
|
|
13
|
-
|
|
14
|
-
approve(callData: Calldata): BytesWriter;
|
|
15
|
-
|
|
16
|
-
allowance(callData: Calldata): BytesWriter;
|
|
17
|
-
|
|
18
|
-
burn(callData: Calldata): BytesWriter;
|
|
19
|
-
|
|
20
|
-
mint(callData: Calldata): BytesWriter;
|
|
21
|
-
}
|
|
1
|
+
import { BytesWriter } from '../../buffer/BytesWriter';
|
|
2
|
+
import { Calldata } from '../../universal/ABIRegistry';
|
|
3
|
+
import { StoredU256 } from '../../storage/StoredU256';
|
|
4
|
+
|
|
5
|
+
export interface IOP_20 {
|
|
6
|
+
readonly _totalSupply: StoredU256;
|
|
7
|
+
|
|
8
|
+
balanceOf(callData: Calldata): BytesWriter;
|
|
9
|
+
|
|
10
|
+
transfer(callData: Calldata): BytesWriter;
|
|
11
|
+
|
|
12
|
+
transferFrom(callData: Calldata): BytesWriter;
|
|
13
|
+
|
|
14
|
+
approve(callData: Calldata): BytesWriter;
|
|
15
|
+
|
|
16
|
+
allowance(callData: Calldata): BytesWriter;
|
|
17
|
+
|
|
18
|
+
burn(callData: Calldata): BytesWriter;
|
|
19
|
+
|
|
20
|
+
mint(callData: Calldata): BytesWriter;
|
|
21
|
+
}
|