@alephium/web3 0.32.1 → 0.34.0
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.
|
@@ -5,6 +5,18 @@ export declare function encodeI256(i256: bigint): Uint8Array;
|
|
|
5
5
|
export declare function encodeU256(u256: bigint): Uint8Array;
|
|
6
6
|
export declare function encodeByteVec(bytes: string): Uint8Array;
|
|
7
7
|
export declare function encodeAddress(address: string): Uint8Array;
|
|
8
|
+
export declare enum VmValType {
|
|
9
|
+
Bool = 0,
|
|
10
|
+
I256 = 1,
|
|
11
|
+
U256 = 2,
|
|
12
|
+
ByteVec = 3,
|
|
13
|
+
Address = 4
|
|
14
|
+
}
|
|
15
|
+
export declare function encodeVmBool(bool: boolean): Uint8Array;
|
|
16
|
+
export declare function encodeVmI256(i256: bigint): Uint8Array;
|
|
17
|
+
export declare function encodeVmU256(u256: bigint): Uint8Array;
|
|
18
|
+
export declare function encodeVmByteVec(bytes: string): Uint8Array;
|
|
19
|
+
export declare function encodeVmAddress(address: string): Uint8Array;
|
|
8
20
|
export declare function encodeScriptFieldAsString(tpe: string, value: Val): string;
|
|
9
21
|
export declare function encodeScriptField(tpe: string, value: Val): Uint8Array;
|
|
10
22
|
export declare function falttenFields(fields: Fields, fieldsSig: FieldsSig): {
|
|
@@ -18,7 +18,7 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18
18
|
*/
|
|
19
19
|
var _a;
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.buildDebugBytecode = exports.encodeContractField = exports.buildContractByteCode = exports.buildScriptByteCode = exports.falttenFields = exports.encodeScriptField = exports.encodeScriptFieldAsString = exports.encodeAddress = exports.encodeByteVec = exports.encodeU256 = exports.encodeI256 = exports.encodeBool = void 0;
|
|
21
|
+
exports.buildDebugBytecode = exports.encodeContractField = exports.buildContractByteCode = exports.buildScriptByteCode = exports.falttenFields = exports.encodeScriptField = exports.encodeScriptFieldAsString = exports.encodeVmAddress = exports.encodeVmByteVec = exports.encodeVmU256 = exports.encodeVmI256 = exports.encodeVmBool = exports.VmValType = exports.encodeAddress = exports.encodeByteVec = exports.encodeU256 = exports.encodeI256 = exports.encodeBool = void 0;
|
|
22
22
|
const buffer_1 = require("buffer/");
|
|
23
23
|
const api_1 = require("../api");
|
|
24
24
|
const utils_1 = require("../utils");
|
|
@@ -164,6 +164,34 @@ function encodeAddress(address) {
|
|
|
164
164
|
return utils_1.bs58.decode(address);
|
|
165
165
|
}
|
|
166
166
|
exports.encodeAddress = encodeAddress;
|
|
167
|
+
var VmValType;
|
|
168
|
+
(function (VmValType) {
|
|
169
|
+
VmValType[VmValType["Bool"] = 0] = "Bool";
|
|
170
|
+
VmValType[VmValType["I256"] = 1] = "I256";
|
|
171
|
+
VmValType[VmValType["U256"] = 2] = "U256";
|
|
172
|
+
VmValType[VmValType["ByteVec"] = 3] = "ByteVec";
|
|
173
|
+
VmValType[VmValType["Address"] = 4] = "Address";
|
|
174
|
+
})(VmValType = exports.VmValType || (exports.VmValType = {}));
|
|
175
|
+
function encodeVmBool(bool) {
|
|
176
|
+
return buffer_1.Buffer.concat([encodeU256(BigInt(VmValType.Bool)), encodeBool(bool)]);
|
|
177
|
+
}
|
|
178
|
+
exports.encodeVmBool = encodeVmBool;
|
|
179
|
+
function encodeVmI256(i256) {
|
|
180
|
+
return buffer_1.Buffer.concat([encodeU256(BigInt(VmValType.I256)), encodeI256(i256)]);
|
|
181
|
+
}
|
|
182
|
+
exports.encodeVmI256 = encodeVmI256;
|
|
183
|
+
function encodeVmU256(u256) {
|
|
184
|
+
return buffer_1.Buffer.concat([encodeU256(BigInt(VmValType.U256)), encodeU256(u256)]);
|
|
185
|
+
}
|
|
186
|
+
exports.encodeVmU256 = encodeVmU256;
|
|
187
|
+
function encodeVmByteVec(bytes) {
|
|
188
|
+
return buffer_1.Buffer.concat([encodeU256(BigInt(VmValType.ByteVec)), encodeByteVec(bytes)]);
|
|
189
|
+
}
|
|
190
|
+
exports.encodeVmByteVec = encodeVmByteVec;
|
|
191
|
+
function encodeVmAddress(address) {
|
|
192
|
+
return buffer_1.Buffer.concat([encodeU256(BigInt(VmValType.Address)), encodeAddress(address)]);
|
|
193
|
+
}
|
|
194
|
+
exports.encodeVmAddress = encodeVmAddress;
|
|
167
195
|
function invalidScriptField(tpe, value) {
|
|
168
196
|
return Error(`Invalid script field ${value} for type ${tpe}`);
|
|
169
197
|
}
|
package/package.json
CHANGED
package/src/contract/ralph.ts
CHANGED
|
@@ -157,6 +157,34 @@ export function encodeAddress(address: string): Uint8Array {
|
|
|
157
157
|
return bs58.decode(address)
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
export enum VmValType {
|
|
161
|
+
Bool = 0,
|
|
162
|
+
I256 = 1,
|
|
163
|
+
U256 = 2,
|
|
164
|
+
ByteVec = 3,
|
|
165
|
+
Address = 4
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function encodeVmBool(bool: boolean): Uint8Array {
|
|
169
|
+
return Buffer.concat([encodeU256(BigInt(VmValType.Bool)), encodeBool(bool)])
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function encodeVmI256(i256: bigint): Uint8Array {
|
|
173
|
+
return Buffer.concat([encodeU256(BigInt(VmValType.I256)), encodeI256(i256)])
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function encodeVmU256(u256: bigint): Uint8Array {
|
|
177
|
+
return Buffer.concat([encodeU256(BigInt(VmValType.U256)), encodeU256(u256)])
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function encodeVmByteVec(bytes: string): Uint8Array {
|
|
181
|
+
return Buffer.concat([encodeU256(BigInt(VmValType.ByteVec)), encodeByteVec(bytes)])
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function encodeVmAddress(address: string): Uint8Array {
|
|
185
|
+
return Buffer.concat([encodeU256(BigInt(VmValType.Address)), encodeAddress(address)])
|
|
186
|
+
}
|
|
187
|
+
|
|
160
188
|
function invalidScriptField(tpe: string, value: Val): Error {
|
|
161
189
|
return Error(`Invalid script field ${value} for type ${tpe}`)
|
|
162
190
|
}
|