@btc-vision/btc-runtime 1.0.6 → 1.0.7

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.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Bitcoin Smart Contract Runtime",
5
5
  "main": "btc/index.ts",
6
6
  "types": "btc/index.ts",
@@ -18,4 +18,4 @@ export declare function deployFromAddress(data: Uint8Array): Uint8Array;
18
18
 
19
19
  // @ts-ignore
20
20
  @external('env', 'call')
21
- export declare function call(calldata: Uint8Array): Uint8Array;
21
+ export declare function call(data: Uint8Array): Uint8Array;
@@ -72,6 +72,35 @@ export class SafeMath {
72
72
  return result;
73
73
  }
74
74
 
75
+ public static min(a: u256, b: u256): u256 {
76
+ return u256.lt(a, b) ? a : b;
77
+ }
78
+
79
+ public static max(a: u256, b: u256): u256 {
80
+ return u256.gt(a, b) ? a : b;
81
+ }
82
+
83
+ @inline
84
+ @unsafe
85
+ public static sqrt(y: u256): u256 {
86
+ if (u256.gt(y, u256.fromU32(3))) {
87
+ let z = y;
88
+
89
+ let x = SafeMath.add(SafeMath.div(y, u256.fromU32(2)), u256.fromU32(1));
90
+ while (u256.lt(x, z)) {
91
+ z = x;
92
+
93
+ let u = SafeMath.div(y, x);
94
+ x = SafeMath.div(u256.add(u, x), u256.fromU32(2));
95
+ }
96
+ return z;
97
+ } else if (!u256.eq(y, u256.Zero)) {
98
+ return u256.fromU32(1);
99
+ } else {
100
+ return u256.Zero;
101
+ }
102
+ }
103
+
75
104
  @inline
76
105
  @unsafe
77
106
  static shl(value: u256, shift: i32): u256 {