@silentswap/sdk 0.0.18 → 0.0.20
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/facilitator-account.d.ts +1 -1
- package/dist/hd-facilitator-group.d.ts +17 -0
- package/dist/hd-facilitator-group.js +31 -1
- package/dist/types/api.d.ts +4 -0
- package/dist/util.d.ts +1 -1
- package/dist/util.js +3 -3
- package/package.json +13 -13
|
@@ -16,7 +16,7 @@ export declare class FacilitatorAccount {
|
|
|
16
16
|
* Exports the secret key
|
|
17
17
|
* @returns A copy of the secret key
|
|
18
18
|
*/
|
|
19
|
-
exportSecretKey(): Uint8Array
|
|
19
|
+
exportSecretKey(): Uint8Array<ArrayBuffer>;
|
|
20
20
|
/**
|
|
21
21
|
* Exports the public key for the given coin type and key type
|
|
22
22
|
* @param coinType coin type
|
|
@@ -14,7 +14,24 @@ export declare class HdFacilitatorGroup {
|
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
16
|
account(coinType: number | CoinTypeStr, addressIndex: number | IntStr): Promise<FacilitatorAccount>;
|
|
17
|
+
/**
|
|
18
|
+
* Derives the viewer account for this group
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
viewer(): Promise<FacilitatorAccount>;
|
|
22
|
+
/**
|
|
23
|
+
* Exports the public keys for each account in this group up to the given count, with the given key specifications
|
|
24
|
+
* @param facilitatorCount - number of facilitator accounts to export
|
|
25
|
+
* @param keySpecs - specifies which keys to exports (coin type and ECDSA key type)
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
17
28
|
exportPublicKeys(facilitatorCount: number, keySpecs: readonly Omit<FacilitatorPublicKey, 'publicKeyBytes'>[]): Promise<FacilitatorPublicKey[][]>;
|
|
29
|
+
/**
|
|
30
|
+
* Approves the given proxy authorization instructions
|
|
31
|
+
* @param instructions - list of instructions to sign
|
|
32
|
+
* @param encryptArgs - arguments to encrypt the keys for export
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
18
35
|
approveProxyAuthorizations(instructions: FacilitatorInstruction[], encryptArgs: EncryptSecretKeyArgs): Promise<FacilitatorReply[]>;
|
|
19
36
|
}
|
|
20
37
|
/**
|
|
@@ -19,8 +19,26 @@ export class HdFacilitatorGroup {
|
|
|
19
19
|
// if global fallback type, use BTC (`0`)
|
|
20
20
|
if ('*' === coinType)
|
|
21
21
|
coinType = '0';
|
|
22
|
-
// derive BIP-32
|
|
22
|
+
// derive BIP-32 node using BIP-44m for intended coin type at group's account index and given address index
|
|
23
23
|
const path = stringToPath(`m/44'/${coinType}'/${this.accountIndex}'/0/${addressIndex}`);
|
|
24
|
+
// derive private key
|
|
25
|
+
const slip10Result = Slip10.derivePath(Slip10Curve.Secp256k1, this.#seed, path);
|
|
26
|
+
// create facilitator account
|
|
27
|
+
try {
|
|
28
|
+
return await new FacilitatorAccount(slip10Result.privkey);
|
|
29
|
+
}
|
|
30
|
+
// destroy the secret key
|
|
31
|
+
finally {
|
|
32
|
+
slip10Result.privkey.fill(0);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Derives the viewer account for this group
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
async viewer() {
|
|
40
|
+
// derive private account BIP-32 node using BIP-44m for BTC at group's account index and "internal" change
|
|
41
|
+
const path = stringToPath(`m/44'/0'/${this.accountIndex}'/1/0`);
|
|
24
42
|
// export private key
|
|
25
43
|
const slip10Result = Slip10.derivePath(Slip10Curve.Secp256k1, this.#seed, path);
|
|
26
44
|
// create facilitator account
|
|
@@ -32,6 +50,12 @@ export class HdFacilitatorGroup {
|
|
|
32
50
|
slip10Result.privkey.fill(0);
|
|
33
51
|
}
|
|
34
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Exports the public keys for each account in this group up to the given count, with the given key specifications
|
|
55
|
+
* @param facilitatorCount - number of facilitator accounts to export
|
|
56
|
+
* @param keySpecs - specifies which keys to exports (coin type and ECDSA key type)
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
35
59
|
async exportPublicKeys(facilitatorCount, keySpecs) {
|
|
36
60
|
const exported = [];
|
|
37
61
|
for (let addrIndex = 0; addrIndex < facilitatorCount; addrIndex++) {
|
|
@@ -44,6 +68,12 @@ export class HdFacilitatorGroup {
|
|
|
44
68
|
}
|
|
45
69
|
return exported;
|
|
46
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Approves the given proxy authorization instructions
|
|
73
|
+
* @param instructions - list of instructions to sign
|
|
74
|
+
* @param encryptArgs - arguments to encrypt the keys for export
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
47
77
|
async approveProxyAuthorizations(instructions, encryptArgs) {
|
|
48
78
|
// each facilitator instruction
|
|
49
79
|
return await Promise.all(instructions.map(async (instruction, facilitatorIndex) => {
|
package/dist/types/api.d.ts
CHANGED
package/dist/util.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Bytesish } from './types/core.js';
|
|
|
4
4
|
* @param bytesIn
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
|
-
export declare function normalizeBytesish(bytesIn: Bytesish): Uint8Array
|
|
7
|
+
export declare function normalizeBytesish(bytesIn: Bytesish): Uint8Array<ArrayBuffer>;
|
|
8
8
|
/**
|
|
9
9
|
* Normalizes a JSON value
|
|
10
10
|
* @param value
|
package/dist/util.js
CHANGED
|
@@ -9,13 +9,13 @@ export function normalizeBytesish(bytesIn) {
|
|
|
9
9
|
let bytesOut;
|
|
10
10
|
// bigint
|
|
11
11
|
if (typeof bytesIn === 'bigint') {
|
|
12
|
-
bytesOut = toBytes(bytesIn);
|
|
12
|
+
bytesOut = toBytes(bytesIn).slice();
|
|
13
13
|
}
|
|
14
14
|
// string argument
|
|
15
15
|
else if (typeof bytesIn === 'string') {
|
|
16
16
|
// "0x..." bytes
|
|
17
17
|
if (bytesIn.startsWith('0x')) {
|
|
18
|
-
bytesOut = hexToBytes(bytesIn);
|
|
18
|
+
bytesOut = hexToBytes(bytesIn).slice();
|
|
19
19
|
}
|
|
20
20
|
// base64
|
|
21
21
|
else {
|
|
@@ -24,7 +24,7 @@ export function normalizeBytesish(bytesIn) {
|
|
|
24
24
|
}
|
|
25
25
|
// bytes
|
|
26
26
|
else if (bytesIn instanceof Uint8Array) {
|
|
27
|
-
bytesOut = bytesIn;
|
|
27
|
+
bytesOut = bytesIn.slice();
|
|
28
28
|
}
|
|
29
29
|
// wasn't set
|
|
30
30
|
if (!bytesOut) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silentswap/sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.20",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"files": [
|
|
@@ -11,26 +11,26 @@
|
|
|
11
11
|
"build": "tsc"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@cosmjs/amino": "0.36.
|
|
15
|
-
"@cosmjs/crypto": "0.36.
|
|
16
|
-
"@cosmjs/encoding": "0.36.
|
|
14
|
+
"@cosmjs/amino": "0.36.2",
|
|
15
|
+
"@cosmjs/crypto": "0.36.2",
|
|
16
|
+
"@cosmjs/encoding": "0.36.2",
|
|
17
17
|
"@solar-republic/wasm-secp256k1": "0.6.3",
|
|
18
18
|
"bignumber.js": "9.3.1",
|
|
19
19
|
"siwe": "3.0.0",
|
|
20
|
-
"viem": "2.
|
|
20
|
+
"viem": "2.38.4"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@eslint/js": "9.
|
|
24
|
-
"@stylistic/eslint-plugin": "5.
|
|
23
|
+
"@eslint/js": "9.38.0",
|
|
24
|
+
"@stylistic/eslint-plugin": "5.5.0",
|
|
25
25
|
"@tsconfig/node24": "24.0.1",
|
|
26
|
-
"@types/node": "24.
|
|
27
|
-
"@types/web": "0.0.
|
|
28
|
-
"@typescript-eslint/parser": "8.
|
|
26
|
+
"@types/node": "24.9.1",
|
|
27
|
+
"@types/web": "0.0.283",
|
|
28
|
+
"@typescript-eslint/parser": "8.46.2",
|
|
29
29
|
"abitype": "1.1.1",
|
|
30
|
-
"eslint": "9.
|
|
30
|
+
"eslint": "9.38.0",
|
|
31
31
|
"eslint-import-resolver-typescript": "4.4.4",
|
|
32
32
|
"eslint-plugin-import-x": "4.16.1",
|
|
33
|
-
"typescript": "5.9.
|
|
34
|
-
"typescript-eslint": "8.
|
|
33
|
+
"typescript": "5.9.3",
|
|
34
|
+
"typescript-eslint": "8.46.2"
|
|
35
35
|
}
|
|
36
36
|
}
|