@xyo-network/wallet-model 3.13.0 → 3.14.1
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/types/Mnemonic.d.ts +27 -0
- package/dist/types/Mnemonic.d.ts.map +1 -0
- package/dist/types/Wallet.d.ts +3 -3
- package/dist/types/Wallet.d.ts.map +1 -1
- package/dist/types/Wordlist.d.ts +24 -0
- package/dist/types/Wordlist.d.ts.map +1 -0
- package/package.json +4 -13
- package/src/Mnemonic.ts +32 -0
- package/src/Wallet.ts +4 -3
- package/src/Wordlist.ts +28 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { WordlistInstance } from './Wordlist.ts';
|
|
2
|
+
export interface MnemonicInstance {
|
|
3
|
+
/**
|
|
4
|
+
* The underlying entropy which the mnemonic encodes.
|
|
5
|
+
*/
|
|
6
|
+
entropy: string;
|
|
7
|
+
/**
|
|
8
|
+
* The password used for this mnemonic. If no password is used this
|
|
9
|
+
* is the empty string (i.e. ``""``) as per the specification.
|
|
10
|
+
*/
|
|
11
|
+
password: string;
|
|
12
|
+
/**
|
|
13
|
+
* The mnemonic phrase of 12, 15, 18, 21 or 24 words.
|
|
14
|
+
*
|
|
15
|
+
* Use the [[wordlist]] ``split`` method to get the individual words.
|
|
16
|
+
*/
|
|
17
|
+
phrase: string;
|
|
18
|
+
/**
|
|
19
|
+
* The wordlist for this mnemonic.
|
|
20
|
+
*/
|
|
21
|
+
wordlist: WordlistInstance;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the seed for the mnemonic.
|
|
24
|
+
*/
|
|
25
|
+
computeSeed(): string;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=Mnemonic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Mnemonic.d.ts","sourceRoot":"","sources":["../../src/Mnemonic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErD,MAAM,WAAW,gBAAgB;IAE/B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IAEf;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAA;IAE1B;;OAEG;IACH,WAAW,IAAI,MAAM,CAAA;CACtB"}
|
package/dist/types/Wallet.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Hex } from '@xylabs/hex';
|
|
2
2
|
import type { AccountConfig, AccountInstance, AccountStatic } from '@xyo-network/account-model';
|
|
3
|
-
import type {
|
|
3
|
+
import type { MnemonicInstance } from './Mnemonic.ts';
|
|
4
4
|
export interface WalletInstance extends AccountInstance {
|
|
5
5
|
readonly chainCode: string;
|
|
6
6
|
readonly depth: number;
|
|
@@ -8,7 +8,7 @@ export interface WalletInstance extends AccountInstance {
|
|
|
8
8
|
readonly extendedKey: string;
|
|
9
9
|
readonly fingerprint: string;
|
|
10
10
|
readonly index: number;
|
|
11
|
-
readonly mnemonic?:
|
|
11
|
+
readonly mnemonic?: MnemonicInstance | null;
|
|
12
12
|
readonly neuter: () => WalletInstance;
|
|
13
13
|
readonly parentFingerprint: string;
|
|
14
14
|
readonly path: string | null;
|
|
@@ -18,7 +18,7 @@ export interface WalletInstance extends AccountInstance {
|
|
|
18
18
|
export interface WalletStatic<T extends WalletInstance = WalletInstance> extends Omit<AccountStatic<T>, 'create'> {
|
|
19
19
|
create(config: AccountConfig): Promise<T>;
|
|
20
20
|
fromExtendedKey(key: string): Promise<T>;
|
|
21
|
-
fromMnemonic(mnemonic:
|
|
21
|
+
fromMnemonic(mnemonic: MnemonicInstance): Promise<T>;
|
|
22
22
|
fromPhrase(mnemonic: string, path?: string): Promise<T>;
|
|
23
23
|
fromSeed(seed: string | ArrayBufferLike): Promise<T>;
|
|
24
24
|
random(): any;
|
|
@@ -1 +1 @@
|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AC,aAAa,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC;IAC/G,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACzC,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACxC,YAAY,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACpD,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IAEpD,MAAM,IAAI,GAAG,CAAA;CACd"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface WordlistInstance {
|
|
2
|
+
locale: string;
|
|
3
|
+
/**
|
|
4
|
+
* Maps an 11-bit value into its coresponding word in the list.
|
|
5
|
+
*
|
|
6
|
+
* Sub-classes MUST override this.
|
|
7
|
+
*/
|
|
8
|
+
getWord(index: number): string;
|
|
9
|
+
/**
|
|
10
|
+
* Maps a word to its corresponding 11-bit value.
|
|
11
|
+
*
|
|
12
|
+
* Sub-classes MUST override this.
|
|
13
|
+
*/
|
|
14
|
+
getWordIndex(word: string): number;
|
|
15
|
+
/**
|
|
16
|
+
* Sub-classes may override this to provider a language-specific
|
|
17
|
+
* method for joining %%words%% into a phrase.
|
|
18
|
+
*
|
|
19
|
+
* By default, %%words%% are joined by a single space.
|
|
20
|
+
*/
|
|
21
|
+
join(words: Array<string>): string;
|
|
22
|
+
split(phrase: string): Array<string>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=Wordlist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Wordlist.d.ts","sourceRoot":"","sources":["../../src/Wordlist.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAA;IAEd;;;;SAIK;IACL,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;IAE9B;;;;SAIK;IACL,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IAElC;;;;;OAKG;IACH,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;IAElC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAA;CAErC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/wallet-model",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.1",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -30,22 +30,13 @@
|
|
|
30
30
|
"types": "dist/types/index.d.ts",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@xylabs/hex": "^4.8.7",
|
|
33
|
-
"@xyo-network/account-model": "^3.
|
|
33
|
+
"@xyo-network/account-model": "^3.14.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@xylabs/ts-scripts-yarn3": "^6.3.
|
|
37
|
-
"@xylabs/tsconfig": "^6.3.
|
|
38
|
-
"ethers": "6.13.6",
|
|
36
|
+
"@xylabs/ts-scripts-yarn3": "^6.3.5",
|
|
37
|
+
"@xylabs/tsconfig": "^6.3.5",
|
|
39
38
|
"typescript": "^5.8.3"
|
|
40
39
|
},
|
|
41
|
-
"peerDependencies": {
|
|
42
|
-
"ethers": "^6"
|
|
43
|
-
},
|
|
44
|
-
"peerDependenciesMeta": {
|
|
45
|
-
"ethers": {
|
|
46
|
-
"optional": true
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
40
|
"publishConfig": {
|
|
50
41
|
"access": "public"
|
|
51
42
|
}
|
package/src/Mnemonic.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { WordlistInstance } from './Wordlist.ts'
|
|
2
|
+
|
|
3
|
+
export interface MnemonicInstance {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The underlying entropy which the mnemonic encodes.
|
|
7
|
+
*/
|
|
8
|
+
entropy: string
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The password used for this mnemonic. If no password is used this
|
|
12
|
+
* is the empty string (i.e. ``""``) as per the specification.
|
|
13
|
+
*/
|
|
14
|
+
password: string
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The mnemonic phrase of 12, 15, 18, 21 or 24 words.
|
|
18
|
+
*
|
|
19
|
+
* Use the [[wordlist]] ``split`` method to get the individual words.
|
|
20
|
+
*/
|
|
21
|
+
phrase: string
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The wordlist for this mnemonic.
|
|
25
|
+
*/
|
|
26
|
+
wordlist: WordlistInstance
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns the seed for the mnemonic.
|
|
30
|
+
*/
|
|
31
|
+
computeSeed(): string
|
|
32
|
+
}
|
package/src/Wallet.ts
CHANGED
|
@@ -2,7 +2,8 @@ import type { Hex } from '@xylabs/hex'
|
|
|
2
2
|
import type {
|
|
3
3
|
AccountConfig, AccountInstance, AccountStatic,
|
|
4
4
|
} from '@xyo-network/account-model'
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
import type { MnemonicInstance } from './Mnemonic.ts'
|
|
6
7
|
|
|
7
8
|
export interface WalletInstance extends AccountInstance {
|
|
8
9
|
readonly chainCode: string
|
|
@@ -11,7 +12,7 @@ export interface WalletInstance extends AccountInstance {
|
|
|
11
12
|
readonly extendedKey: string
|
|
12
13
|
readonly fingerprint: string
|
|
13
14
|
readonly index: number
|
|
14
|
-
readonly mnemonic?:
|
|
15
|
+
readonly mnemonic?: MnemonicInstance | null
|
|
15
16
|
readonly neuter: () => WalletInstance
|
|
16
17
|
readonly parentFingerprint: string
|
|
17
18
|
readonly path: string | null
|
|
@@ -22,7 +23,7 @@ export interface WalletInstance extends AccountInstance {
|
|
|
22
23
|
export interface WalletStatic<T extends WalletInstance = WalletInstance> extends Omit<AccountStatic<T>, 'create'> {
|
|
23
24
|
create(config: AccountConfig): Promise<T>
|
|
24
25
|
fromExtendedKey(key: string): Promise<T>
|
|
25
|
-
fromMnemonic(mnemonic:
|
|
26
|
+
fromMnemonic(mnemonic: MnemonicInstance): Promise<T>
|
|
26
27
|
fromPhrase(mnemonic: string, path?: string): Promise<T>
|
|
27
28
|
fromSeed(seed: string | ArrayBufferLike): Promise<T>
|
|
28
29
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/src/Wordlist.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface WordlistInstance {
|
|
2
|
+
locale: string
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Maps an 11-bit value into its coresponding word in the list.
|
|
6
|
+
*
|
|
7
|
+
* Sub-classes MUST override this.
|
|
8
|
+
*/
|
|
9
|
+
getWord(index: number): string
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Maps a word to its corresponding 11-bit value.
|
|
13
|
+
*
|
|
14
|
+
* Sub-classes MUST override this.
|
|
15
|
+
*/
|
|
16
|
+
getWordIndex(word: string): number
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Sub-classes may override this to provider a language-specific
|
|
20
|
+
* method for joining %%words%% into a phrase.
|
|
21
|
+
*
|
|
22
|
+
* By default, %%words%% are joined by a single space.
|
|
23
|
+
*/
|
|
24
|
+
join(words: Array<string>): string
|
|
25
|
+
|
|
26
|
+
split(phrase: string): Array<string>
|
|
27
|
+
|
|
28
|
+
}
|