xpi-ts 0.2.3 → 0.2.5
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/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/jest.config.d.ts +27 -0
- package/dist/jest.config.d.ts.map +1 -0
- package/dist/jest.config.js +37 -0
- package/dist/utils/wallet.d.ts +11 -5
- package/dist/utils/wallet.d.ts.map +1 -1
- package/dist/utils/wallet.js +14 -6
- package/jest.config.js +37 -0
- package/package.json +14 -3
- package/dist/utils/types.d.ts +0 -2
- package/dist/utils/types.d.ts.map +0 -1
- package/dist/utils/types.js +0 -1
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAKA,cAAc,cAAc,CAAA;AAC5B,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AACjD,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAC3C,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAKA,cAAc,cAAc,CAAA;AAC5B,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AACjD,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAC3C,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
let preset: string;
|
|
3
|
+
let testEnvironment: string;
|
|
4
|
+
let roots: string[];
|
|
5
|
+
let testMatch: string[];
|
|
6
|
+
let moduleFileExtensions: string[];
|
|
7
|
+
let collectCoverageFrom: string[];
|
|
8
|
+
let coveragePathIgnorePatterns: string[];
|
|
9
|
+
let transform: {
|
|
10
|
+
'^.+\\.tsx?$': (string | {
|
|
11
|
+
useESM: boolean;
|
|
12
|
+
tsconfig: {
|
|
13
|
+
module: string;
|
|
14
|
+
target: string;
|
|
15
|
+
esModuleInterop: boolean;
|
|
16
|
+
allowSyntheticDefaultImports: boolean;
|
|
17
|
+
};
|
|
18
|
+
})[];
|
|
19
|
+
};
|
|
20
|
+
let extensionsToTreatAsEsm: string[];
|
|
21
|
+
let moduleNameMapper: {
|
|
22
|
+
'^(\\.{1,2}/.*)\\.js$': string;
|
|
23
|
+
'^@/(.*)$': string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export default _default;
|
|
27
|
+
//# sourceMappingURL=jest.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.config.d.ts","sourceRoot":"","sources":["../jest.config.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
preset: 'ts-jest',
|
|
3
|
+
testEnvironment: 'node',
|
|
4
|
+
roots: ['<rootDir>'],
|
|
5
|
+
testMatch: ['**/test/**/*.test.ts'],
|
|
6
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
|
|
7
|
+
collectCoverageFrom: [
|
|
8
|
+
'lib/**/*.ts',
|
|
9
|
+
'utils/**/*.ts',
|
|
10
|
+
'!lib/**/*.d.ts',
|
|
11
|
+
'!utils/**/*.d.ts',
|
|
12
|
+
'!**/node_modules/**',
|
|
13
|
+
'!**/dist/**',
|
|
14
|
+
],
|
|
15
|
+
coveragePathIgnorePatterns: [
|
|
16
|
+
'/node_modules/',
|
|
17
|
+
'/dist/',
|
|
18
|
+
'/test/',
|
|
19
|
+
'/examples/',
|
|
20
|
+
],
|
|
21
|
+
transform: {
|
|
22
|
+
'^.+\\.tsx?$': ['ts-jest', {
|
|
23
|
+
useESM: true,
|
|
24
|
+
tsconfig: {
|
|
25
|
+
module: 'ES2022',
|
|
26
|
+
target: 'ES2022',
|
|
27
|
+
esModuleInterop: true,
|
|
28
|
+
allowSyntheticDefaultImports: true,
|
|
29
|
+
},
|
|
30
|
+
}],
|
|
31
|
+
},
|
|
32
|
+
extensionsToTreatAsEsm: ['.ts'],
|
|
33
|
+
moduleNameMapper: {
|
|
34
|
+
'^(\\.{1,2}/.*)\\.js$': '$1',
|
|
35
|
+
'^@/(.*)$': '<rootDir>/$1',
|
|
36
|
+
},
|
|
37
|
+
};
|
package/dist/utils/wallet.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { Address, Script, ScriptType, Mnemonic } from '../lib/bitcore/index.js';
|
|
1
|
+
import { Address, Script, ScriptType, Mnemonic, Network } from '../lib/bitcore/index.js';
|
|
2
2
|
export interface Wallet {
|
|
3
|
-
hdPrivateKey
|
|
4
|
-
privateKey
|
|
5
|
-
publicKey
|
|
3
|
+
hdPrivateKey?: string;
|
|
4
|
+
privateKey?: string;
|
|
5
|
+
publicKey?: string;
|
|
6
6
|
address: Address;
|
|
7
7
|
script: Script;
|
|
8
8
|
scriptPayload: string;
|
|
9
9
|
scriptType: ScriptType;
|
|
10
10
|
}
|
|
11
|
-
export
|
|
11
|
+
export type WalletWithKeys = Required<Wallet>;
|
|
12
|
+
export declare function createWallet({ mnemonic, path, network, scriptType, }: {
|
|
13
|
+
mnemonic?: Mnemonic | string;
|
|
14
|
+
path?: string;
|
|
15
|
+
network?: Network;
|
|
16
|
+
scriptType?: ScriptType;
|
|
17
|
+
}): Wallet | WalletWithKeys;
|
|
12
18
|
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../utils/wallet.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,OAAO,EAEP,MAAM,EACN,UAAU,EACV,QAAQ,
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../utils/wallet.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,OAAO,EAEP,MAAM,EACN,UAAU,EACV,QAAQ,EACR,OAAO,EAER,MAAM,yBAAyB,CAAA;AAKhC,MAAM,WAAW,MAAM;IAErB,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,OAAO,EAAE,OAAO,CAAA;IAEhB,MAAM,EAAE,MAAM,CAAA;IAEd,aAAa,EAAE,MAAM,CAAA;IAErB,UAAU,EAAE,UAAU,CAAA;CACvB;AAGD,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;AA2B7C,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,IAAI,EACJ,OAA0B,EAC1B,UAAoB,GACrB,EAAE;IACD,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,UAAU,CAAC,EAAE,UAAU,CAAA;CACxB,GAAG,MAAM,GAAG,cAAc,CAiC1B"}
|
package/dist/utils/wallet.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Networks, Script, Mnemonic, } from '../lib/bitcore/index.js';
|
|
2
|
-
|
|
1
|
+
import { Networks, Script, Mnemonic, buildKeyPathTaproot, } from '../lib/bitcore/index.js';
|
|
2
|
+
import { BIP44_COIN_TYPE } from './constants.js';
|
|
3
|
+
export function createWallet({ mnemonic, path, network = Networks.mainnet, scriptType = 'p2pkh', }) {
|
|
3
4
|
if (mnemonic) {
|
|
4
5
|
if (typeof mnemonic === 'string') {
|
|
5
6
|
mnemonic = new Mnemonic(mnemonic);
|
|
@@ -9,18 +10,25 @@ export function createWallet(mnemonic, path) {
|
|
|
9
10
|
mnemonic = new Mnemonic();
|
|
10
11
|
}
|
|
11
12
|
if (!path) {
|
|
12
|
-
path =
|
|
13
|
+
path = `m/44'/${BIP44_COIN_TYPE}'/0'/0/0`;
|
|
13
14
|
}
|
|
14
15
|
const hdPrivateKey = mnemonic.toHDPrivateKey();
|
|
15
16
|
const privateKey = hdPrivateKey.deriveChild(path).privateKey;
|
|
16
17
|
const publicKey = privateKey.publicKey;
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
let script = undefined;
|
|
19
|
+
switch (scriptType) {
|
|
20
|
+
case 'p2tr-commitment':
|
|
21
|
+
script = buildKeyPathTaproot(publicKey);
|
|
22
|
+
break;
|
|
23
|
+
default:
|
|
24
|
+
script = Script.buildPublicKeyHashOut(publicKey);
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
19
27
|
return {
|
|
20
28
|
hdPrivateKey: hdPrivateKey.toString(),
|
|
21
29
|
privateKey: privateKey.toWIF(),
|
|
22
30
|
publicKey: publicKey.toString(),
|
|
23
|
-
address:
|
|
31
|
+
address: script.toAddress(network),
|
|
24
32
|
script: script,
|
|
25
33
|
scriptType: script.getType(),
|
|
26
34
|
scriptPayload: script.getData().toString('hex'),
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
preset: 'ts-jest',
|
|
3
|
+
testEnvironment: 'node',
|
|
4
|
+
roots: ['<rootDir>'],
|
|
5
|
+
testMatch: ['**/test/**/*.test.ts'],
|
|
6
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
|
|
7
|
+
collectCoverageFrom: [
|
|
8
|
+
'lib/**/*.ts',
|
|
9
|
+
'utils/**/*.ts',
|
|
10
|
+
'!lib/**/*.d.ts',
|
|
11
|
+
'!utils/**/*.d.ts',
|
|
12
|
+
'!**/node_modules/**',
|
|
13
|
+
'!**/dist/**',
|
|
14
|
+
],
|
|
15
|
+
coveragePathIgnorePatterns: [
|
|
16
|
+
'/node_modules/',
|
|
17
|
+
'/dist/',
|
|
18
|
+
'/test/',
|
|
19
|
+
'/examples/',
|
|
20
|
+
],
|
|
21
|
+
transform: {
|
|
22
|
+
'^.+\\.tsx?$': ['ts-jest', {
|
|
23
|
+
useESM: true,
|
|
24
|
+
tsconfig: {
|
|
25
|
+
module: 'ES2022',
|
|
26
|
+
target: 'ES2022',
|
|
27
|
+
esModuleInterop: true,
|
|
28
|
+
allowSyntheticDefaultImports: true,
|
|
29
|
+
},
|
|
30
|
+
}],
|
|
31
|
+
},
|
|
32
|
+
extensionsToTreatAsEsm: ['.ts'],
|
|
33
|
+
moduleNameMapper: {
|
|
34
|
+
'^(\\.{1,2}/.*)\\.js$': '$1',
|
|
35
|
+
'^@/(.*)$': '<rootDir>/$1',
|
|
36
|
+
},
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xpi-ts",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Bitcore-compatible wallet SDK for Lotus",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -40,10 +40,17 @@
|
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "tsc",
|
|
43
|
+
"build:watch": "tsc --watch",
|
|
44
|
+
"format": "prettier --write .",
|
|
45
|
+
"format:check": "prettier --check .",
|
|
46
|
+
"lint": "eslint .",
|
|
47
|
+
"lint:fix": "eslint . --fix",
|
|
48
|
+
"test": "jest",
|
|
49
|
+
"test:watch": "jest --watch",
|
|
50
|
+
"test:coverage": "jest --coverage",
|
|
43
51
|
"prepublishOnly": "npm run build",
|
|
44
52
|
"version": "npm run build",
|
|
45
|
-
"postversion": "git push && git push --tags"
|
|
46
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
53
|
+
"postversion": "git push && git push --tags"
|
|
47
54
|
},
|
|
48
55
|
"engines": {
|
|
49
56
|
"node": ">=22.0.0"
|
|
@@ -74,11 +81,15 @@
|
|
|
74
81
|
"elliptic": "^6.6.1"
|
|
75
82
|
},
|
|
76
83
|
"devDependencies": {
|
|
84
|
+
"@eslint/js": "^9.0.0",
|
|
77
85
|
"@types/bn.js": "5.2.0",
|
|
78
86
|
"@types/bs58": "4.0.4",
|
|
79
87
|
"@types/elliptic": "6.4.18",
|
|
88
|
+
"@types/jest": "^29.5.0",
|
|
80
89
|
"@types/node": "24.0.10",
|
|
90
|
+
"jest": "^29.7.0",
|
|
81
91
|
"prettier": "3.6.2",
|
|
92
|
+
"ts-jest": "^29.1.0",
|
|
82
93
|
"tsx": "^4.21.0",
|
|
83
94
|
"typescript": "5.8.3",
|
|
84
95
|
"typescript-eslint": "8.47.0"
|
package/dist/utils/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../utils/types.ts"],"names":[],"mappings":""}
|
package/dist/utils/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|