@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.
@@ -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 nodem using BIP-44m for intended coin type at group's account index and given address index
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) => {
@@ -44,6 +44,10 @@ export type QuoteRequest = {
44
44
  * Address of the quote signer
45
45
  */
46
46
  signer: Hex;
47
+ /**
48
+ * Public key of the group viewer
49
+ */
50
+ viewer: Hex;
47
51
  /**
48
52
  * Privacy setting
49
53
  */
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.18",
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.0",
15
- "@cosmjs/crypto": "0.36.0",
16
- "@cosmjs/encoding": "0.36.0",
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.37.6"
20
+ "viem": "2.38.4"
21
21
  },
22
22
  "devDependencies": {
23
- "@eslint/js": "9.35.0",
24
- "@stylistic/eslint-plugin": "5.3.1",
23
+ "@eslint/js": "9.38.0",
24
+ "@stylistic/eslint-plugin": "5.5.0",
25
25
  "@tsconfig/node24": "24.0.1",
26
- "@types/node": "24.5.2",
27
- "@types/web": "0.0.269",
28
- "@typescript-eslint/parser": "8.44.0",
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.35.0",
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.2",
34
- "typescript-eslint": "8.44.0"
33
+ "typescript": "5.9.3",
34
+ "typescript-eslint": "8.46.2"
35
35
  }
36
36
  }