@xyo-network/wallet 7.0.14 → 7.0.15
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/neutral/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from '@xyo-network/sdk-protocol/wallet';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,kCAAkC,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,157 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
5
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
6
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7
|
-
if (decorator = decorators[i])
|
|
8
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
9
|
-
if (kind && result) __defProp(target, key, result);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
13
|
-
|
|
14
|
-
// src/HDWallet.ts
|
|
15
|
-
import {
|
|
16
|
-
asAddress,
|
|
17
|
-
assertEx,
|
|
18
|
-
globallyUnique,
|
|
19
|
-
hexFromHexString,
|
|
20
|
-
staticImplements,
|
|
21
|
-
toUint8Array
|
|
22
|
-
} from "@ariestools/sdk";
|
|
23
|
-
import { generateMnemonic } from "@scure/bip39";
|
|
24
|
-
import { wordlist as englishWordlist } from "@scure/bip39/wordlists/english.js";
|
|
25
|
-
import { Account, PrivateKey } from "@xyo-network/account";
|
|
26
|
-
import {
|
|
27
|
-
isMnemonicInitializationConfig,
|
|
28
|
-
isPhraseInitializationConfig,
|
|
29
|
-
isPrivateKeyInitializationConfig
|
|
30
|
-
} from "@xyo-network/account-model";
|
|
31
|
-
import {
|
|
32
|
-
defaultPath,
|
|
33
|
-
HDNodeWallet,
|
|
34
|
-
Mnemonic
|
|
35
|
-
} from "ethers";
|
|
36
|
-
var HDWallet = class extends Account {
|
|
37
|
-
node;
|
|
38
|
-
neuter = () => {
|
|
39
|
-
this.node.neuter();
|
|
40
|
-
return this;
|
|
41
|
-
};
|
|
42
|
-
constructor(key, node, privateKey) {
|
|
43
|
-
super(key, privateKey);
|
|
44
|
-
this.node = node;
|
|
45
|
-
}
|
|
46
|
-
static async createFromNodeInternal(node, previousHash) {
|
|
47
|
-
const privateKey = toUint8Array(node.privateKey.replace("0x", ""));
|
|
48
|
-
assertEx(privateKey.length === 32, () => `Private key must be 32 bytes [${privateKey?.length}]`);
|
|
49
|
-
const key = await PrivateKey.create(privateKey.buffer);
|
|
50
|
-
const wallet = new HDWallet(super._protectedConstructorKey, node, key);
|
|
51
|
-
const newWallet = await wallet.loadPreviousHash(previousHash);
|
|
52
|
-
return this._addressMap[newWallet.address]?.deref() ?? newWallet;
|
|
53
|
-
}
|
|
54
|
-
static getCachedWalletOrCacheNewWallet(createdWallet) {
|
|
55
|
-
const existingWallet = this._addressMap[createdWallet.address]?.deref();
|
|
56
|
-
if (existingWallet) {
|
|
57
|
-
return existingWallet;
|
|
58
|
-
}
|
|
59
|
-
const ref = new WeakRef(createdWallet);
|
|
60
|
-
this._addressMap[createdWallet.address] = ref;
|
|
61
|
-
return createdWallet;
|
|
62
|
-
}
|
|
63
|
-
static async create(opts) {
|
|
64
|
-
if (isPhraseInitializationConfig(opts)) {
|
|
65
|
-
return await this.fromPhrase(opts.phrase);
|
|
66
|
-
}
|
|
67
|
-
if (isMnemonicInitializationConfig(opts)) {
|
|
68
|
-
return await this.fromPhrase(opts.mnemonic, opts.path);
|
|
69
|
-
}
|
|
70
|
-
if (isPrivateKeyInitializationConfig(opts)) {
|
|
71
|
-
throw new Error("Invalid initialization config. from privateKey not supported. Use Account.fromPrivateKey instead.");
|
|
72
|
-
}
|
|
73
|
-
throw new Error("Invalid initialization config");
|
|
74
|
-
}
|
|
75
|
-
static async createFromNode(node, previousHash) {
|
|
76
|
-
return await this.createFromNodeInternal(node, previousHash);
|
|
77
|
-
}
|
|
78
|
-
static async fromExtendedKey(key) {
|
|
79
|
-
const node = HDNodeWallet.fromExtendedKey(key);
|
|
80
|
-
return await this.createFromNode(node);
|
|
81
|
-
}
|
|
82
|
-
static async fromMnemonic(mnemonic, path = defaultPath) {
|
|
83
|
-
const node = HDNodeWallet.fromMnemonic(mnemonic, path);
|
|
84
|
-
const createdWallet = await this.createFromNodeInternal(node);
|
|
85
|
-
return this.getCachedWalletOrCacheNewWallet(createdWallet);
|
|
86
|
-
}
|
|
87
|
-
static async fromPhrase(phrase, path = defaultPath) {
|
|
88
|
-
return await this.fromMnemonic(Mnemonic.fromPhrase(phrase), path);
|
|
89
|
-
}
|
|
90
|
-
static async fromSeed(seed) {
|
|
91
|
-
const node = HDNodeWallet.fromSeed(toUint8Array(seed));
|
|
92
|
-
const createdWallet = await this.createFromNodeInternal(node);
|
|
93
|
-
return this.getCachedWalletOrCacheNewWallet(createdWallet);
|
|
94
|
-
}
|
|
95
|
-
static generateMnemonic(wordlist = englishWordlist, strength = 256) {
|
|
96
|
-
return generateMnemonic(wordlist, strength);
|
|
97
|
-
}
|
|
98
|
-
static async random() {
|
|
99
|
-
return await this.fromMnemonic(Mnemonic.fromPhrase(this.generateMnemonic()));
|
|
100
|
-
}
|
|
101
|
-
get address() {
|
|
102
|
-
return asAddress(hexFromHexString(this.node.address, { prefix: false }), true);
|
|
103
|
-
}
|
|
104
|
-
get addressBytes() {
|
|
105
|
-
return toUint8Array(this.address, void 0, 16).buffer;
|
|
106
|
-
}
|
|
107
|
-
get chainCode() {
|
|
108
|
-
return this.node.chainCode;
|
|
109
|
-
}
|
|
110
|
-
get depth() {
|
|
111
|
-
return this.node.depth;
|
|
112
|
-
}
|
|
113
|
-
get extendedKey() {
|
|
114
|
-
return this.node.extendedKey;
|
|
115
|
-
}
|
|
116
|
-
get fingerprint() {
|
|
117
|
-
return this.node.fingerprint;
|
|
118
|
-
}
|
|
119
|
-
get index() {
|
|
120
|
-
return this.node.index;
|
|
121
|
-
}
|
|
122
|
-
get mnemonic() {
|
|
123
|
-
return this.node.mnemonic;
|
|
124
|
-
}
|
|
125
|
-
get parentFingerprint() {
|
|
126
|
-
return this.node.parentFingerprint;
|
|
127
|
-
}
|
|
128
|
-
get path() {
|
|
129
|
-
return this.node.path;
|
|
130
|
-
}
|
|
131
|
-
get privateKey() {
|
|
132
|
-
return this.node.privateKey.toLowerCase();
|
|
133
|
-
}
|
|
134
|
-
get publicKey() {
|
|
135
|
-
return this.node.publicKey.toLowerCase();
|
|
136
|
-
}
|
|
137
|
-
async derivePath(path) {
|
|
138
|
-
if (path.startsWith("m/")) {
|
|
139
|
-
const parentPath = this.path;
|
|
140
|
-
if (parentPath !== null && path.startsWith(parentPath)) {
|
|
141
|
-
const childPath = path.slice(parentPath.length + 1);
|
|
142
|
-
return await HDWallet.createFromNode(this.node.derivePath(childPath));
|
|
143
|
-
}
|
|
144
|
-
throw new Error(`Invalid absolute path ${path} for wallet with path ${parentPath}`);
|
|
145
|
-
}
|
|
146
|
-
return await HDWallet.createFromNode(this.node.derivePath(path));
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
__publicField(HDWallet, "uniqueName", globallyUnique("HDWallet", HDWallet, "xyo"));
|
|
150
|
-
__publicField(HDWallet, "_addressMap", {});
|
|
151
|
-
HDWallet = __decorateClass([
|
|
152
|
-
staticImplements()
|
|
153
|
-
], HDWallet);
|
|
154
|
-
export {
|
|
155
|
-
HDWallet
|
|
156
|
-
};
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export * from "@xyo-network/sdk-protocol/wallet";
|
|
157
3
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Compatibility shim: this package re-exports from @xyo-network/sdk-protocol.\nexport * from '@xyo-network/sdk-protocol/wallet'\n"],
|
|
5
|
+
"mappings": ";AACA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/wallet",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.15",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -34,41 +34,51 @@
|
|
|
34
34
|
"README.md"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@xyo-network/
|
|
38
|
-
"@xyo-network/account-model": "~7.0.14",
|
|
39
|
-
"@xyo-network/account": "~7.0.14",
|
|
40
|
-
"@xyo-network/wallet-model": "~7.0.14",
|
|
41
|
-
"@xyo-network/key-model": "~7.0.14"
|
|
37
|
+
"@xyo-network/sdk-protocol": "~7.0.15"
|
|
42
38
|
},
|
|
43
39
|
"devDependencies": {
|
|
44
40
|
"@ariestools/sdk": "~8.0.2",
|
|
45
|
-
"@ariestools/
|
|
41
|
+
"@ariestools/threads": "~8.0.2",
|
|
46
42
|
"@bitauth/libauth": "~3.0.0",
|
|
43
|
+
"@metamask/providers": "~22.1.1",
|
|
44
|
+
"@noble/post-quantum": "~0.6.1",
|
|
47
45
|
"@opentelemetry/api": "~1.9.1",
|
|
48
46
|
"@opentelemetry/sdk-trace-base": "~2.9.0",
|
|
49
47
|
"@scure/base": "~2.2.0",
|
|
50
48
|
"@scure/bip39": "~2.2.0",
|
|
51
|
-
"@xylabs/toolchain": "~8.6.
|
|
52
|
-
"@xylabs/tsconfig": "~8.6.
|
|
49
|
+
"@xylabs/toolchain": "~8.6.7",
|
|
50
|
+
"@xylabs/tsconfig": "~8.6.7",
|
|
51
|
+
"ajv": "~8.20.0",
|
|
53
52
|
"async-mutex": "~0.5.0",
|
|
53
|
+
"debug": "~4.4.3",
|
|
54
54
|
"eslint": "~10.6.0",
|
|
55
55
|
"eslint-import-resolver-typescript": "~4.4.5",
|
|
56
56
|
"ethers": "~6.17.0",
|
|
57
|
-
"
|
|
57
|
+
"hash-wasm": "~4.12.0",
|
|
58
|
+
"idb": "~8.0.3",
|
|
59
|
+
"observable-fns": "~0.6.1",
|
|
58
60
|
"typescript": "~6.0.3",
|
|
59
|
-
"
|
|
60
|
-
"vitest": "~4.1.9",
|
|
61
|
+
"webextension-polyfill": "~0.12.0",
|
|
61
62
|
"zod": "~4.4.3"
|
|
62
63
|
},
|
|
63
64
|
"peerDependencies": {
|
|
64
65
|
"@ariestools/sdk": "^8.0.2",
|
|
66
|
+
"@ariestools/threads": "^8.0.2",
|
|
65
67
|
"@bitauth/libauth": "^3.0.0",
|
|
68
|
+
"@metamask/providers": "^22.1.1",
|
|
69
|
+
"@noble/post-quantum": "^0.6.1",
|
|
66
70
|
"@opentelemetry/api": "^1.9.1",
|
|
67
71
|
"@opentelemetry/sdk-trace-base": "^2.9.0",
|
|
68
72
|
"@scure/base": "^2.2.0",
|
|
69
73
|
"@scure/bip39": "^2.2.0",
|
|
74
|
+
"ajv": "^8.20.0",
|
|
70
75
|
"async-mutex": "^0.5.0",
|
|
76
|
+
"debug": "^4.4.3",
|
|
71
77
|
"ethers": "^6.17.0",
|
|
78
|
+
"hash-wasm": "^4.12.0",
|
|
79
|
+
"idb": "^8.0.3",
|
|
80
|
+
"observable-fns": "^0.6.1",
|
|
81
|
+
"webextension-polyfill": "^0.12.0",
|
|
72
82
|
"zod": "^4.4.3"
|
|
73
83
|
},
|
|
74
84
|
"engines": {
|
|
@@ -76,5 +86,6 @@
|
|
|
76
86
|
},
|
|
77
87
|
"publishConfig": {
|
|
78
88
|
"access": "public"
|
|
79
|
-
}
|
|
89
|
+
},
|
|
90
|
+
"deprecated": "Use @xyo-network/sdk-protocol/wallet instead. Replace @xyo-network/wallet with @xyo-network/sdk-protocol/wallet. This package is a compatibility shim only and will not receive further updates."
|
|
80
91
|
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { Hex } from '@ariestools/sdk';
|
|
2
|
-
import { Account } from '@xyo-network/account';
|
|
3
|
-
import type { AccountConfig } from '@xyo-network/account-model';
|
|
4
|
-
import type { XyoAddress } from '@xyo-network/address';
|
|
5
|
-
import type { PrivateKeyInstance } from '@xyo-network/key-model';
|
|
6
|
-
import type { WalletInstance } from '@xyo-network/wallet-model';
|
|
7
|
-
import { HDNodeWallet, Mnemonic } from 'ethers';
|
|
8
|
-
export declare class HDWallet extends Account implements WalletInstance {
|
|
9
|
-
static readonly uniqueName: string;
|
|
10
|
-
protected static _addressMap: Record<XyoAddress, WeakRef<WalletInstance>>;
|
|
11
|
-
protected readonly node: HDNodeWallet;
|
|
12
|
-
neuter: () => HDWallet;
|
|
13
|
-
constructor(key: symbol, node: HDNodeWallet, privateKey: PrivateKeyInstance);
|
|
14
|
-
protected static createFromNodeInternal(node: HDNodeWallet, previousHash?: string): Promise<WalletInstance>;
|
|
15
|
-
protected static getCachedWalletOrCacheNewWallet(createdWallet: WalletInstance): WalletInstance;
|
|
16
|
-
static create(opts?: AccountConfig): Promise<WalletInstance>;
|
|
17
|
-
static createFromNode(node: HDNodeWallet, previousHash?: string): Promise<WalletInstance>;
|
|
18
|
-
static fromExtendedKey(key: string): Promise<WalletInstance>;
|
|
19
|
-
static fromMnemonic(mnemonic: Mnemonic, path?: string): Promise<WalletInstance>;
|
|
20
|
-
static fromPhrase(phrase: string, path?: string): Promise<WalletInstance>;
|
|
21
|
-
static fromSeed(seed: string | ArrayBufferLike): Promise<WalletInstance>;
|
|
22
|
-
static generateMnemonic(wordlist?: string[], strength?: number): string;
|
|
23
|
-
static random(): Promise<WalletInstance>;
|
|
24
|
-
get address(): XyoAddress;
|
|
25
|
-
get addressBytes(): ArrayBufferLike;
|
|
26
|
-
get chainCode(): string;
|
|
27
|
-
get depth(): number;
|
|
28
|
-
get extendedKey(): string;
|
|
29
|
-
get fingerprint(): string;
|
|
30
|
-
get index(): number;
|
|
31
|
-
get mnemonic(): Mnemonic | null;
|
|
32
|
-
get parentFingerprint(): string;
|
|
33
|
-
get path(): string | null;
|
|
34
|
-
get privateKey(): Hex;
|
|
35
|
-
get publicKey(): Hex;
|
|
36
|
-
derivePath(path: string): Promise<WalletInstance>;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=HDWallet.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HDWallet.d.ts","sourceRoot":"","sources":["../../src/HDWallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAM1C,OAAO,EAAE,OAAO,EAAc,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAM/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,2BAA2B,CAAA;AAC7E,OAAO,EACQ,YAAY,EAAE,QAAQ,EACpC,MAAM,QAAQ,CAAA;AAEf,qBACa,QAAS,SAAQ,OAAQ,YAAW,cAAc;IAC7D,gBAAyB,UAAU,SAA8C;IACjF,iBAA0B,WAAW,EAAE,MAAM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