@btc-vision/btc-runtime 1.4.0 → 1.4.2
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
|
@@ -17,6 +17,7 @@ import { IOP_20 } from './interfaces/IOP_20';
|
|
|
17
17
|
import { OP20InitParameters } from './interfaces/OP20InitParameters';
|
|
18
18
|
import { OP_NET } from './OP_NET';
|
|
19
19
|
import { sha256 } from '../env/global';
|
|
20
|
+
import { ApproveStr, TransferFromStr, TransferStr } from '../shared-libraries/TransferHelper';
|
|
20
21
|
|
|
21
22
|
const maxSupplyPointer: u16 = Blockchain.nextPointer;
|
|
22
23
|
const decimalsPointer: u16 = Blockchain.nextPointer;
|
|
@@ -208,7 +209,7 @@ export abstract class DeployableOP_20 extends OP_NET implements IOP_20 {
|
|
|
208
209
|
break;
|
|
209
210
|
case encodeSelector('allowance(address,address)'):
|
|
210
211
|
return this.allowance(calldata);
|
|
211
|
-
case encodeSelector(
|
|
212
|
+
case encodeSelector(ApproveStr):
|
|
212
213
|
return this.approve(calldata);
|
|
213
214
|
case encodeSelector('approveFrom(address,address,uint256,bytes)'):
|
|
214
215
|
return this.approveFrom(calldata);
|
|
@@ -216,9 +217,9 @@ export abstract class DeployableOP_20 extends OP_NET implements IOP_20 {
|
|
|
216
217
|
return this.balanceOf(calldata);
|
|
217
218
|
case encodeSelector('burn(uint256)'):
|
|
218
219
|
return this.burn(calldata);
|
|
219
|
-
case encodeSelector(
|
|
220
|
+
case encodeSelector(TransferStr):
|
|
220
221
|
return this.transfer(calldata);
|
|
221
|
-
case encodeSelector(
|
|
222
|
+
case encodeSelector(TransferFromStr):
|
|
222
223
|
return this.transferFrom(calldata);
|
|
223
224
|
default:
|
|
224
225
|
return super.execute(method, calldata);
|
|
@@ -3,11 +3,11 @@ import { BytesWriter } from '../buffer/BytesWriter';
|
|
|
3
3
|
import { Blockchain } from '../env';
|
|
4
4
|
import { encodeSelector, Selector } from '../math/abi';
|
|
5
5
|
import { Address } from '../types/Address';
|
|
6
|
-
import { ADDRESS_BYTE_LENGTH, SELECTOR_BYTE_LENGTH } from '../utils
|
|
6
|
+
import { ADDRESS_BYTE_LENGTH, SELECTOR_BYTE_LENGTH } from '../utils';
|
|
7
7
|
|
|
8
8
|
export class OP20Utils {
|
|
9
9
|
public static get BALANCE_OF_SELECTOR(): Selector {
|
|
10
|
-
return encodeSelector('balanceOf');
|
|
10
|
+
return encodeSelector('balanceOf(address)');
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
public static balanceOf(token: Address, owner: Address): u256 {
|
|
@@ -4,19 +4,23 @@ import { Blockchain } from '../env';
|
|
|
4
4
|
import { encodeSelector, Selector } from '../math/abi';
|
|
5
5
|
import { Address } from '../types/Address';
|
|
6
6
|
import { Revert } from '../types/Revert';
|
|
7
|
-
import { ADDRESS_BYTE_LENGTH, SELECTOR_BYTE_LENGTH, U256_BYTE_LENGTH } from '../utils
|
|
7
|
+
import { ADDRESS_BYTE_LENGTH, SELECTOR_BYTE_LENGTH, U256_BYTE_LENGTH } from '../utils';
|
|
8
|
+
|
|
9
|
+
export const TransferStr = 'transfer(address,uint256)';
|
|
10
|
+
export const ApproveStr = 'approve(address,uint256)';
|
|
11
|
+
export const TransferFromStr = 'transferFrom(address,address,uint256)';
|
|
8
12
|
|
|
9
13
|
export class TransferHelper {
|
|
10
14
|
public static get APPROVE_SELECTOR(): Selector {
|
|
11
|
-
return encodeSelector(
|
|
15
|
+
return encodeSelector(ApproveStr);
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
public static get TRANSFER_SELECTOR(): Selector {
|
|
15
|
-
return encodeSelector(
|
|
19
|
+
return encodeSelector(TransferStr);
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
public static get TRANSFER_FROM_SELECTOR(): Selector {
|
|
19
|
-
return encodeSelector(
|
|
23
|
+
return encodeSelector(TransferFromStr);
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
public static safeApprove(token: Address, spender: Address, amount: u256): void {
|