@alephium/web3 0.3.0-rc.0 → 0.3.0-rc.3
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/dist/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/src/api/api-alephium.d.ts +1 -1
- package/dist/src/contract/contract.js +1 -1
- package/dist/src/utils/utils.d.ts +6 -1
- package/dist/src/utils/utils.js +7 -3
- package/package.json +3 -2
- package/src/api/api-alephium.ts +1 -1
- package/src/contract/contract.ts +1 -1
- package/src/utils/utils.ts +5 -1
|
@@ -347,7 +347,7 @@ export interface CompilerOptions {
|
|
|
347
347
|
ignoreUnusedFieldsWarnings?: boolean;
|
|
348
348
|
ignoreUnusedPrivateFunctionsWarnings?: boolean;
|
|
349
349
|
ignoreUpdateFieldsCheckWarnings?: boolean;
|
|
350
|
-
|
|
350
|
+
ignoreCheckExternalCallerWarnings?: boolean;
|
|
351
351
|
}
|
|
352
352
|
export interface Confirmed {
|
|
353
353
|
/** @format block-hash */
|
|
@@ -66,7 +66,7 @@ exports.DEFAULT_NODE_COMPILER_OPTIONS = {
|
|
|
66
66
|
ignoreUnusedFieldsWarnings: false,
|
|
67
67
|
ignoreUnusedPrivateFunctionsWarnings: false,
|
|
68
68
|
ignoreUpdateFieldsCheckWarnings: false,
|
|
69
|
-
|
|
69
|
+
ignoreCheckExternalCallerWarnings: false
|
|
70
70
|
};
|
|
71
71
|
exports.DEFAULT_COMPILER_OPTIONS = { errorOnWarnings: true, ...exports.DEFAULT_NODE_COMPILER_OPTIONS };
|
|
72
72
|
class TypedMatcher {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { ec as EC, SignatureInput } from 'elliptic';
|
|
2
|
-
|
|
2
|
+
import BN from 'bn.js';
|
|
3
|
+
export declare function encodeSignature(signature: EC.Signature | {
|
|
4
|
+
r: BN;
|
|
5
|
+
s: BN;
|
|
6
|
+
}): string;
|
|
7
|
+
export declare function encodeHexSignature(rHex: string, sHex: string): string;
|
|
3
8
|
export declare function signatureDecode(ec: EC, signature: string): SignatureInput;
|
|
4
9
|
export declare function xorByte(intValue: number): number;
|
|
5
10
|
export declare function isHexString(input: string): boolean;
|
package/dist/src/utils/utils.js
CHANGED
|
@@ -20,7 +20,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
20
20
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.assertType = exports.timeout = exports.hexToString = exports.stringToHex = exports.subContractId = exports.contractIdFromTx = exports.addressFromContractId = exports.addressFromPublicKey = exports.publicKeyFromPrivateKey = exports.groupOfPrivateKey = exports.binToHex = exports.hexToBinUnsafe = exports.tokenIdFromAddress = exports.contractIdFromAddress = exports.groupOfAddress = exports.isHexString = exports.xorByte = exports.signatureDecode = exports.
|
|
23
|
+
exports.assertType = exports.timeout = exports.hexToString = exports.stringToHex = exports.subContractId = exports.contractIdFromTx = exports.addressFromContractId = exports.addressFromPublicKey = exports.publicKeyFromPrivateKey = exports.groupOfPrivateKey = exports.binToHex = exports.hexToBinUnsafe = exports.tokenIdFromAddress = exports.contractIdFromAddress = exports.groupOfAddress = exports.isHexString = exports.xorByte = exports.signatureDecode = exports.encodeHexSignature = exports.encodeSignature = void 0;
|
|
24
24
|
const elliptic_1 = require("elliptic");
|
|
25
25
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
26
26
|
const blakejs_1 = __importDefault(require("blakejs"));
|
|
@@ -29,7 +29,7 @@ const buffer_1 = require("buffer/");
|
|
|
29
29
|
const constants_1 = require("../constants");
|
|
30
30
|
const djb2_1 = __importDefault(require("./djb2"));
|
|
31
31
|
const ec = new elliptic_1.ec('secp256k1');
|
|
32
|
-
function
|
|
32
|
+
function encodeSignature(signature) {
|
|
33
33
|
let sNormalized = signature.s;
|
|
34
34
|
if (ec.n && signature.s.cmp(ec.nh) === 1) {
|
|
35
35
|
sNormalized = ec.n.sub(signature.s);
|
|
@@ -38,7 +38,11 @@ function signatureEncode(signature) {
|
|
|
38
38
|
const s = sNormalized.toString('hex', 66).slice(2);
|
|
39
39
|
return r + s;
|
|
40
40
|
}
|
|
41
|
-
exports.
|
|
41
|
+
exports.encodeSignature = encodeSignature;
|
|
42
|
+
function encodeHexSignature(rHex, sHex) {
|
|
43
|
+
return encodeSignature({ r: new bn_js_1.default(rHex, 'hex'), s: new bn_js_1.default(sHex, 'hex') });
|
|
44
|
+
}
|
|
45
|
+
exports.encodeHexSignature = encodeHexSignature;
|
|
42
46
|
// the signature should be in hex string format for 64 bytes
|
|
43
47
|
function signatureDecode(ec, signature) {
|
|
44
48
|
if (signature.length !== 128) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alephium/web3",
|
|
3
|
-
"version": "0.3.0-rc.
|
|
3
|
+
"version": "0.3.0-rc.3",
|
|
4
4
|
"description": "A JS/TS library to interact with the Alephium platform",
|
|
5
5
|
"license": "GPL",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"author": "Alephium dev <dev@alephium.org>",
|
|
29
29
|
"config": {
|
|
30
|
-
"alephium_version": "1.6.0-
|
|
30
|
+
"alephium_version": "1.6.0-rc5",
|
|
31
31
|
"explorer_backend_version": "1.11.2"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@babel/eslint-parser": "^7.18.9",
|
|
52
|
+
"@types/elliptic": "^6.4.13",
|
|
52
53
|
"@types/find-up": "^2.1.0",
|
|
53
54
|
"@types/fs-extra": "^9.0.13",
|
|
54
55
|
"@types/jest": "^27.5.1",
|
package/src/api/api-alephium.ts
CHANGED
|
@@ -472,7 +472,7 @@ export interface CompilerOptions {
|
|
|
472
472
|
ignoreUnusedFieldsWarnings?: boolean
|
|
473
473
|
ignoreUnusedPrivateFunctionsWarnings?: boolean
|
|
474
474
|
ignoreUpdateFieldsCheckWarnings?: boolean
|
|
475
|
-
|
|
475
|
+
ignoreCheckExternalCallerWarnings?: boolean
|
|
476
476
|
}
|
|
477
477
|
|
|
478
478
|
export interface Confirmed {
|
package/src/contract/contract.ts
CHANGED
|
@@ -70,7 +70,7 @@ export const DEFAULT_NODE_COMPILER_OPTIONS: node.CompilerOptions = {
|
|
|
70
70
|
ignoreUnusedFieldsWarnings: false,
|
|
71
71
|
ignoreUnusedPrivateFunctionsWarnings: false,
|
|
72
72
|
ignoreUpdateFieldsCheckWarnings: false,
|
|
73
|
-
|
|
73
|
+
ignoreCheckExternalCallerWarnings: false
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export const DEFAULT_COMPILER_OPTIONS: CompilerOptions = { errorOnWarnings: true, ...DEFAULT_NODE_COMPILER_OPTIONS }
|
package/src/utils/utils.ts
CHANGED
|
@@ -27,7 +27,7 @@ import djb2 from './djb2'
|
|
|
27
27
|
|
|
28
28
|
const ec = new EC('secp256k1')
|
|
29
29
|
|
|
30
|
-
export function
|
|
30
|
+
export function encodeSignature(signature: EC.Signature | { r: BN; s: BN }): string {
|
|
31
31
|
let sNormalized = signature.s
|
|
32
32
|
if (ec.n && signature.s.cmp(ec.nh) === 1) {
|
|
33
33
|
sNormalized = ec.n.sub(signature.s)
|
|
@@ -38,6 +38,10 @@ export function signatureEncode(signature: EC.Signature): string {
|
|
|
38
38
|
return r + s
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
export function encodeHexSignature(rHex: string, sHex: string): string {
|
|
42
|
+
return encodeSignature({ r: new BN(rHex, 'hex'), s: new BN(sHex, 'hex') })
|
|
43
|
+
}
|
|
44
|
+
|
|
41
45
|
// the signature should be in hex string format for 64 bytes
|
|
42
46
|
export function signatureDecode(ec: EC, signature: string): SignatureInput {
|
|
43
47
|
if (signature.length !== 128) {
|