@btc-vision/btc-runtime 1.3.4 → 1.3.5
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@btc-vision/btc-runtime",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "Bitcoin Smart Contract Runtime",
|
|
5
5
|
"main": "btc/index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@assemblyscript/loader": "^0.27.30",
|
|
46
46
|
"@eslint/js": "^9.10.0",
|
|
47
|
-
"as-bignum": "^0.3.
|
|
47
|
+
"as-bignum": "^0.3.1",
|
|
48
48
|
"gulplog": "^2.2.0",
|
|
49
49
|
"mocha": "^10.7.3",
|
|
50
50
|
"ts-node": "^10.9.2",
|
|
@@ -216,8 +216,12 @@ export abstract class DeployableOP_20 extends OP_NET implements IOP_20 {
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
protected _approve(owner: Address, spender: Address, value: u256): boolean {
|
|
219
|
-
if (owner === Blockchain.DEAD_ADDRESS
|
|
220
|
-
throw new Revert('
|
|
219
|
+
if (owner === Blockchain.DEAD_ADDRESS) {
|
|
220
|
+
throw new Revert('Address can not be dead address');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (spender === Blockchain.DEAD_ADDRESS) {
|
|
224
|
+
throw new Revert('Spender cannot be dead address');
|
|
221
225
|
}
|
|
222
226
|
|
|
223
227
|
const senderMap = this.allowanceMap.get(owner);
|
|
@@ -22,10 +22,6 @@ export class OP_NET implements IBTC {
|
|
|
22
22
|
let response: BytesWriter;
|
|
23
23
|
|
|
24
24
|
switch (method) {
|
|
25
|
-
case encodeSelector('address'):
|
|
26
|
-
response = new BytesWriter(ADDRESS_BYTE_LENGTH);
|
|
27
|
-
response.writeAddress(this.address);
|
|
28
|
-
break;
|
|
29
25
|
case encodeSelector('owner'):
|
|
30
26
|
response = new BytesWriter(ADDRESS_BYTE_LENGTH);
|
|
31
27
|
response.writeAddress(this.owner);
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
loadPointer,
|
|
18
18
|
log,
|
|
19
19
|
storePointer,
|
|
20
|
+
validateBitcoinAddress,
|
|
20
21
|
} from './global';
|
|
21
22
|
import { DeployContractResponse } from '../interfaces/DeployContractResponse';
|
|
22
23
|
import { MapU256 } from '../generic/MapU256';
|
|
@@ -162,6 +163,14 @@ export class BlockchainEnvironment {
|
|
|
162
163
|
emit(buffer.getBuffer());
|
|
163
164
|
}
|
|
164
165
|
|
|
166
|
+
public validateBitcoinAddress(address: string): bool {
|
|
167
|
+
const writer = new BytesWriter(address.length);
|
|
168
|
+
writer.writeString(address);
|
|
169
|
+
|
|
170
|
+
const reader = new BytesReader(validateBitcoinAddress(writer.getBuffer()));
|
|
171
|
+
return reader.readBoolean();
|
|
172
|
+
}
|
|
173
|
+
|
|
165
174
|
public encodeVirtualAddress(virtualAddress: u8[]): Address {
|
|
166
175
|
const writer: BytesWriter = new BytesWriter(virtualAddress.length + 4);
|
|
167
176
|
writer.writeU32(virtualAddress.length);
|
package/runtime/env/global.ts
CHANGED
|
@@ -38,6 +38,10 @@ export declare function sha256(data: Uint8Array): Uint8Array;
|
|
|
38
38
|
@external('env', 'ripemd160')
|
|
39
39
|
export declare function ripemd160(data: Uint8Array): Uint8Array;
|
|
40
40
|
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
@external('env', 'validateBitcoinAddress')
|
|
43
|
+
export declare function validateBitcoinAddress(data: Uint8Array): Uint8Array;
|
|
44
|
+
|
|
41
45
|
// @ts-ignore
|
|
42
46
|
@external('env', 'inputs')
|
|
43
47
|
export declare function inputs(): Uint8Array;
|
|
@@ -25,17 +25,6 @@ export class MultiAddressMemoryMap<V extends MemorySlotData<u256>> extends Map<
|
|
|
25
25
|
return super.get(key);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
public setUpperKey(key: Address, key2: Address, value: V): this {
|
|
29
|
-
this.createKeyMerger(key);
|
|
30
|
-
|
|
31
|
-
const subMap = super.get(key);
|
|
32
|
-
if (subMap) {
|
|
33
|
-
subMap.set(key2, value);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
28
|
public set(key: Address, value: Uint8ArrayMerger<V>): this {
|
|
40
29
|
this.createKeyMerger(key);
|
|
41
30
|
|