@btc-vision/btc-runtime 1.4.6 → 1.4.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 +1 -1
- package/runtime/storage/arrays/StoredAddressArray.ts +5 -4
- package/runtime/storage/arrays/StoredBooleanArray.ts +7 -4
- package/runtime/storage/arrays/StoredU128Array.ts +6 -5
- package/runtime/storage/arrays/StoredU16Array.ts +6 -4
- package/runtime/storage/arrays/StoredU256Array.ts +5 -4
- package/runtime/storage/arrays/StoredU32Array.ts +6 -4
- package/runtime/storage/arrays/StoredU8Array.ts +6 -4
package/package.json
CHANGED
|
@@ -65,12 +65,13 @@ export class StoredAddressArray {
|
|
|
65
65
|
*/
|
|
66
66
|
@inline
|
|
67
67
|
public get(index: u64): Address {
|
|
68
|
-
if (index
|
|
69
|
-
throw new Revert('
|
|
68
|
+
if (index > this.MAX_LENGTH) {
|
|
69
|
+
throw new Revert('Operation failed: Index exceeds maximum allowed value.');
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
const slotIndex: u32 = <u32>index;
|
|
73
73
|
this.ensureValues(slotIndex);
|
|
74
|
+
|
|
74
75
|
const value = this._values.get(slotIndex);
|
|
75
76
|
return value ? value : this.defaultValue;
|
|
76
77
|
}
|
|
@@ -189,8 +190,8 @@ export class StoredAddressArray {
|
|
|
189
190
|
* @param {u64} index - The global index of the Address value to delete.
|
|
190
191
|
*/
|
|
191
192
|
public delete(index: u64): void {
|
|
192
|
-
if (index
|
|
193
|
-
throw new Revert('
|
|
193
|
+
if (index > this.MAX_LENGTH) {
|
|
194
|
+
throw new Revert('Operation failed: Index exceeds maximum allowed value.');
|
|
194
195
|
}
|
|
195
196
|
|
|
196
197
|
const slotIndex: u32 = <u32>index;
|
|
@@ -64,13 +64,15 @@ export class StoredBooleanArray {
|
|
|
64
64
|
*/
|
|
65
65
|
@inline
|
|
66
66
|
public get(index: u64): bool {
|
|
67
|
-
if (index
|
|
68
|
-
|
|
67
|
+
if (index > this.MAX_LENGTH) {
|
|
68
|
+
throw new Revert('Operation failed: Index exceeds maximum allowed value.');
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const slotIndex: u64 = index / 256; // Each slot holds 256 bits
|
|
72
72
|
const bitIndex: u16 = <u16>(index % 256); // 0 to 255
|
|
73
|
+
|
|
73
74
|
this.ensureValues(slotIndex);
|
|
75
|
+
|
|
74
76
|
const slotValue = this._values.get(slotIndex);
|
|
75
77
|
if (slotValue) {
|
|
76
78
|
return this.getBit(slotValue, bitIndex);
|
|
@@ -121,6 +123,7 @@ export class StoredBooleanArray {
|
|
|
121
123
|
const effectiveIndex: u64 = this._startIndex + newIndex;
|
|
122
124
|
const wrappedIndex: u64 =
|
|
123
125
|
effectiveIndex < this.MAX_LENGTH ? effectiveIndex : effectiveIndex % this.MAX_LENGTH;
|
|
126
|
+
|
|
124
127
|
const slotIndex: u64 = wrappedIndex / 256;
|
|
125
128
|
const bitIndex: u8 = <u8>(wrappedIndex % 256);
|
|
126
129
|
|
|
@@ -145,8 +148,8 @@ export class StoredBooleanArray {
|
|
|
145
148
|
* @param {u64} index - The global index of the boolean value to delete.
|
|
146
149
|
*/
|
|
147
150
|
public delete(index: u64): void {
|
|
148
|
-
if (index
|
|
149
|
-
throw new Revert('
|
|
151
|
+
if (index > this.MAX_LENGTH) {
|
|
152
|
+
throw new Revert('Operation failed: Index exceeds maximum allowed value.');
|
|
150
153
|
}
|
|
151
154
|
|
|
152
155
|
const slotIndex: u64 = index / 256;
|
|
@@ -64,13 +64,15 @@ export class StoredU128Array {
|
|
|
64
64
|
*/
|
|
65
65
|
@inline
|
|
66
66
|
public get(index: u64): u128 {
|
|
67
|
-
if (index
|
|
68
|
-
|
|
67
|
+
if (index > this.MAX_LENGTH) {
|
|
68
|
+
throw new Revert('Operation failed: Index exceeds maximum allowed value.');
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const slotIndex: u32 = <u32>(index / 2); // Each slot holds two u128s
|
|
72
72
|
const subIndex: u8 = <u8>(index % 2); // 0 or 1
|
|
73
|
+
|
|
73
74
|
this.ensureValues(slotIndex);
|
|
75
|
+
|
|
74
76
|
const slotValues = this._values.get(slotIndex);
|
|
75
77
|
if (slotValues) {
|
|
76
78
|
return slotValues[subIndex];
|
|
@@ -142,9 +144,8 @@ export class StoredU128Array {
|
|
|
142
144
|
* @param {u64} index - The global index of the u128 value to delete.
|
|
143
145
|
*/
|
|
144
146
|
public delete(index: u64): void {
|
|
145
|
-
if (index
|
|
146
|
-
|
|
147
|
-
throw new Revert('Delete operation failed: Index out of bounds.');
|
|
147
|
+
if (index > this.MAX_LENGTH) {
|
|
148
|
+
throw new Revert('Operation failed: Index exceeds maximum allowed value.');
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
const slotIndex: u32 = <u32>(index / 2);
|
|
@@ -64,13 +64,15 @@ export class StoredU16Array {
|
|
|
64
64
|
*/
|
|
65
65
|
@inline
|
|
66
66
|
public get(index: u64): u16 {
|
|
67
|
-
if (index
|
|
68
|
-
|
|
67
|
+
if (index > this.MAX_LENGTH) {
|
|
68
|
+
throw new Revert('Operation failed: Index exceeds maximum allowed value.');
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const slotIndex: u64 = index / 16; // Each slot holds sixteen u16s
|
|
72
72
|
const subIndex: u8 = <u8>(index % 16); // 0 to 15
|
|
73
|
+
|
|
73
74
|
this.ensureValues(slotIndex);
|
|
75
|
+
|
|
74
76
|
const slotValues = this._values.get(slotIndex);
|
|
75
77
|
return slotValues ? slotValues[subIndex] : 0;
|
|
76
78
|
}
|
|
@@ -138,8 +140,8 @@ export class StoredU16Array {
|
|
|
138
140
|
* @param {u64} index - The global index of the u16 value to delete.
|
|
139
141
|
*/
|
|
140
142
|
public delete(index: u64): void {
|
|
141
|
-
if (index
|
|
142
|
-
throw new Revert('
|
|
143
|
+
if (index > this.MAX_LENGTH) {
|
|
144
|
+
throw new Revert('Operation failed: Index exceeds maximum allowed value.');
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
const slotIndex: u64 = index / 16;
|
|
@@ -65,12 +65,13 @@ export class StoredU256Array {
|
|
|
65
65
|
*/
|
|
66
66
|
@inline
|
|
67
67
|
public get(index: u64): u256 {
|
|
68
|
-
if (index
|
|
69
|
-
|
|
68
|
+
if (index > this.MAX_LENGTH) {
|
|
69
|
+
throw new Revert('Operation failed: Index exceeds maximum allowed value.');
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
const slotIndex: u32 = <u32>index;
|
|
73
73
|
this.ensureValues(slotIndex);
|
|
74
|
+
|
|
74
75
|
const value = this._values.get(slotIndex);
|
|
75
76
|
return value ? value : u256.Zero;
|
|
76
77
|
}
|
|
@@ -157,8 +158,8 @@ export class StoredU256Array {
|
|
|
157
158
|
* @param {u64} index - The global index of the u256 value to delete.
|
|
158
159
|
*/
|
|
159
160
|
public delete(index: u64): void {
|
|
160
|
-
if (index
|
|
161
|
-
throw new Revert('
|
|
161
|
+
if (index > this.MAX_LENGTH) {
|
|
162
|
+
throw new Revert('Operation failed: Index exceeds maximum allowed value.');
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
const slotIndex: u32 = <u32>index;
|
|
@@ -65,13 +65,15 @@ export class StoredU32Array {
|
|
|
65
65
|
*/
|
|
66
66
|
@inline
|
|
67
67
|
public get(index: u64): u32 {
|
|
68
|
-
if (index
|
|
69
|
-
|
|
68
|
+
if (index > this.MAX_LENGTH) {
|
|
69
|
+
throw new Revert('Operation failed: Index exceeds maximum allowed value.');
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
const slotIndex: u64 = index / 8; // Each slot holds 8 u32s
|
|
73
73
|
const subIndex: u8 = <u8>(index % 8); // 0..7
|
|
74
|
+
|
|
74
75
|
this.ensureValues(slotIndex);
|
|
76
|
+
|
|
75
77
|
const slotValues = this._values.get(slotIndex);
|
|
76
78
|
return slotValues ? slotValues[subIndex] : 0;
|
|
77
79
|
}
|
|
@@ -139,8 +141,8 @@ export class StoredU32Array {
|
|
|
139
141
|
* @param {u64} index - The global index of the u32 value to delete.
|
|
140
142
|
*/
|
|
141
143
|
public delete(index: u64): void {
|
|
142
|
-
if (index
|
|
143
|
-
throw new Revert('
|
|
144
|
+
if (index > this.MAX_LENGTH) {
|
|
145
|
+
throw new Revert('Operation failed: Index exceeds maximum allowed value.');
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
const slotIndex: u64 = index / 8;
|
|
@@ -63,13 +63,15 @@ export class StoredU8Array {
|
|
|
63
63
|
*/
|
|
64
64
|
@inline
|
|
65
65
|
public get(index: u64): u8 {
|
|
66
|
-
if (index
|
|
67
|
-
|
|
66
|
+
if (index > this.MAX_LENGTH) {
|
|
67
|
+
throw new Revert('Operation failed: Index exceeds maximum allowed value.');
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
const slotIndex: u64 = index / 32; // Each slot holds thirty-two u8s
|
|
71
71
|
const subIndex: u8 = <u8>(index % 32);
|
|
72
|
+
|
|
72
73
|
this.ensureValues(slotIndex);
|
|
74
|
+
|
|
73
75
|
const slotValues = this._values.get(slotIndex);
|
|
74
76
|
return slotValues ? slotValues[subIndex] : 0;
|
|
75
77
|
}
|
|
@@ -134,8 +136,8 @@ export class StoredU8Array {
|
|
|
134
136
|
* @param {u64} index - The global index of the u8 value to delete.
|
|
135
137
|
*/
|
|
136
138
|
public delete(index: u64): void {
|
|
137
|
-
if (index
|
|
138
|
-
throw new Revert('
|
|
139
|
+
if (index > this.MAX_LENGTH) {
|
|
140
|
+
throw new Revert('Operation failed: Index exceeds maximum allowed value.');
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
const slotIndex: u64 = index / 32;
|