@acala-network/chopsticks-utils 1.0.2-2 → 1.0.3

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.
@@ -1,11 +1,11 @@
1
+ import { type StorageValues } from '@acala-network/chopsticks';
2
+ import type { NewBlockParams } from '@acala-network/chopsticks-core/rpc/dev/new-block.js';
3
+ import type { Config } from '@acala-network/chopsticks/schema/index.js';
1
4
  import { ApiPromise, WsProvider } from '@polkadot/api';
2
- import { StorageValues } from '@acala-network/chopsticks';
3
- import { Codec } from '@polkadot/types/types';
4
- import { Config } from '@acala-network/chopsticks/schema/index.js';
5
- import { HexString } from '@polkadot/util/types';
5
+ import type { SubmittableExtrinsic } from '@polkadot/api-base/types';
6
6
  import { Keyring } from '@polkadot/keyring';
7
- import { NewBlockParams } from '@acala-network/chopsticks-core/rpc/dev/new-block.js';
8
- import { SubmittableExtrinsic } from '@polkadot/api-base/types';
7
+ import type { Codec } from '@polkadot/types/types';
8
+ import type { HexString } from '@polkadot/util/types';
9
9
  export * from './signFake.js';
10
10
  /**
11
11
  * Configuration options for setting up a blockchain network instance
@@ -165,3 +165,17 @@ export declare const testingPairs: (keyringType?: "ed25519" | "sr25519", ss58For
165
165
  keyring: Keyring;
166
166
  keyringEth: import("@polkadot/keyring/types").KeyringInstance;
167
167
  };
168
+ /**
169
+ * Creates a set of test signers for either Ed25519 or Sr25519.
170
+ * @param keyringType Type of keyring to use for substrate addresses ('ed25519' or 'sr25519')
171
+ * @returns Object containing various test signers, and a `polkadotSignerBuilder` function to create more.
172
+ */
173
+ export declare const testingSigners: (keyringType?: "Ed25519" | "Sr25519") => {
174
+ alice: import("@polkadot-api/polkadot-signer").PolkadotSigner;
175
+ bob: import("@polkadot-api/polkadot-signer").PolkadotSigner;
176
+ charlie: import("@polkadot-api/polkadot-signer").PolkadotSigner;
177
+ dave: import("@polkadot-api/polkadot-signer").PolkadotSigner;
178
+ eve: import("@polkadot-api/polkadot-signer").PolkadotSigner;
179
+ ferdie: import("@polkadot-api/polkadot-signer").PolkadotSigner;
180
+ polkadotSignerBuilder: (path: string, keyringType?: "Ed25519" | "Sr25519") => import("@polkadot-api/polkadot-signer").PolkadotSigner;
181
+ };
package/dist/cjs/index.js CHANGED
@@ -29,11 +29,17 @@ _export(exports, {
29
29
  },
30
30
  testingPairs: function() {
31
31
  return testingPairs;
32
+ },
33
+ testingSigners: function() {
34
+ return testingSigners;
32
35
  }
33
36
  });
34
- const _api = require("@polkadot/api");
35
37
  const _chopsticks = require("@acala-network/chopsticks");
38
+ const _hdkd = require("@polkadot-labs/hdkd");
39
+ const _hdkdhelpers = require("@polkadot-labs/hdkd-helpers");
40
+ const _api = require("@polkadot/api");
36
41
  const _keyring = require("@polkadot/keyring");
42
+ const _signer = require("polkadot-api/signer");
37
43
  _export_star(require("./signFake.js"), exports);
38
44
  function _export_star(from, to) {
39
45
  Object.keys(from).forEach(function(k) {
@@ -210,3 +216,22 @@ const testingPairs = (keyringType = 'ed25519', ss58Format)=>{
210
216
  keyringEth
211
217
  };
212
218
  };
219
+ const testingSigners = (keyringType = 'Ed25519')=>{
220
+ const entropy = (0, _hdkdhelpers.mnemonicToEntropy)(_hdkdhelpers.DEV_PHRASE);
221
+ const miniSecret = (0, _hdkdhelpers.entropyToMiniSecret)(entropy);
222
+ const derive = keyringType === 'Ed25519' ? (0, _hdkd.ed25519CreateDerive)(miniSecret) : (0, _hdkd.sr25519CreateDerive)(miniSecret);
223
+ // Create a PAPI polkadot signer given a derivation path e.g. "//Alice" or "//Bob".
224
+ const polkadotSignerBuilder = (path, keyringType = 'Ed25519')=>{
225
+ const hdkdKeyPair = derive(path);
226
+ return (0, _signer.getPolkadotSigner)(hdkdKeyPair.publicKey, keyringType, hdkdKeyPair.sign);
227
+ };
228
+ return {
229
+ alice: polkadotSignerBuilder('//Alice', keyringType),
230
+ bob: polkadotSignerBuilder('//Bob', keyringType),
231
+ charlie: polkadotSignerBuilder('//Charlie', keyringType),
232
+ dave: polkadotSignerBuilder('//Dave', keyringType),
233
+ eve: polkadotSignerBuilder('//Eve', keyringType),
234
+ ferdie: polkadotSignerBuilder('//Ferdie', keyringType),
235
+ polkadotSignerBuilder
236
+ };
237
+ };
@@ -1,6 +1,6 @@
1
- import { ApiPromise } from '@polkadot/api';
2
- import { GenericExtrinsic } from '@polkadot/types';
3
- import { SignatureOptions } from '@polkadot/types/types';
1
+ import type { ApiPromise } from '@polkadot/api';
2
+ import type { GenericExtrinsic } from '@polkadot/types';
3
+ import type { SignatureOptions } from '@polkadot/types/types';
4
4
  export type SignFakeOptions = Partial<SignatureOptions>;
5
5
  export declare const signFakeWithApi: (api: ApiPromise, tx: GenericExtrinsic, addr: string, options?: SignFakeOptions) => Promise<void>;
6
6
  export declare const signFake: (tx: GenericExtrinsic, addr: string, options: SignatureOptions) => void;
@@ -1,11 +1,11 @@
1
+ import { type StorageValues } from '@acala-network/chopsticks';
2
+ import type { NewBlockParams } from '@acala-network/chopsticks-core/rpc/dev/new-block.js';
3
+ import type { Config } from '@acala-network/chopsticks/schema/index.js';
1
4
  import { ApiPromise, WsProvider } from '@polkadot/api';
2
- import { StorageValues } from '@acala-network/chopsticks';
3
- import { Codec } from '@polkadot/types/types';
4
- import { Config } from '@acala-network/chopsticks/schema/index.js';
5
- import { HexString } from '@polkadot/util/types';
5
+ import type { SubmittableExtrinsic } from '@polkadot/api-base/types';
6
6
  import { Keyring } from '@polkadot/keyring';
7
- import { NewBlockParams } from '@acala-network/chopsticks-core/rpc/dev/new-block.js';
8
- import { SubmittableExtrinsic } from '@polkadot/api-base/types';
7
+ import type { Codec } from '@polkadot/types/types';
8
+ import type { HexString } from '@polkadot/util/types';
9
9
  export * from './signFake.js';
10
10
  /**
11
11
  * Configuration options for setting up a blockchain network instance
@@ -165,3 +165,17 @@ export declare const testingPairs: (keyringType?: "ed25519" | "sr25519", ss58For
165
165
  keyring: Keyring;
166
166
  keyringEth: import("@polkadot/keyring/types").KeyringInstance;
167
167
  };
168
+ /**
169
+ * Creates a set of test signers for either Ed25519 or Sr25519.
170
+ * @param keyringType Type of keyring to use for substrate addresses ('ed25519' or 'sr25519')
171
+ * @returns Object containing various test signers, and a `polkadotSignerBuilder` function to create more.
172
+ */
173
+ export declare const testingSigners: (keyringType?: "Ed25519" | "Sr25519") => {
174
+ alice: import("@polkadot-api/polkadot-signer").PolkadotSigner;
175
+ bob: import("@polkadot-api/polkadot-signer").PolkadotSigner;
176
+ charlie: import("@polkadot-api/polkadot-signer").PolkadotSigner;
177
+ dave: import("@polkadot-api/polkadot-signer").PolkadotSigner;
178
+ eve: import("@polkadot-api/polkadot-signer").PolkadotSigner;
179
+ ferdie: import("@polkadot-api/polkadot-signer").PolkadotSigner;
180
+ polkadotSignerBuilder: (path: string, keyringType?: "Ed25519" | "Sr25519") => import("@polkadot-api/polkadot-signer").PolkadotSigner;
181
+ };
package/dist/esm/index.js CHANGED
@@ -1,6 +1,9 @@
1
- import { ApiPromise, WsProvider } from '@polkadot/api';
2
1
  import { BuildBlockMode, connectParachains, connectVertical, defaultLogger, environment, fetchConfig, setupWithServer } from '@acala-network/chopsticks';
2
+ import { ed25519CreateDerive, sr25519CreateDerive } from '@polkadot-labs/hdkd';
3
+ import { DEV_PHRASE, entropyToMiniSecret, mnemonicToEntropy } from '@polkadot-labs/hdkd-helpers';
4
+ import { ApiPromise, WsProvider } from '@polkadot/api';
3
5
  import { Keyring, createTestKeyring } from '@polkadot/keyring';
6
+ import { getPolkadotSigner } from 'polkadot-api/signer';
4
7
  const logger = defaultLogger.child({
5
8
  name: 'utils'
6
9
  });
@@ -192,3 +195,26 @@ export * from './signFake.js';
192
195
  keyringEth
193
196
  };
194
197
  };
198
+ /**
199
+ * Creates a set of test signers for either Ed25519 or Sr25519.
200
+ * @param keyringType Type of keyring to use for substrate addresses ('ed25519' or 'sr25519')
201
+ * @returns Object containing various test signers, and a `polkadotSignerBuilder` function to create more.
202
+ */ export const testingSigners = (keyringType = 'Ed25519')=>{
203
+ const entropy = mnemonicToEntropy(DEV_PHRASE);
204
+ const miniSecret = entropyToMiniSecret(entropy);
205
+ const derive = keyringType === 'Ed25519' ? ed25519CreateDerive(miniSecret) : sr25519CreateDerive(miniSecret);
206
+ // Create a PAPI polkadot signer given a derivation path e.g. "//Alice" or "//Bob".
207
+ const polkadotSignerBuilder = (path, keyringType = 'Ed25519')=>{
208
+ const hdkdKeyPair = derive(path);
209
+ return getPolkadotSigner(hdkdKeyPair.publicKey, keyringType, hdkdKeyPair.sign);
210
+ };
211
+ return {
212
+ alice: polkadotSignerBuilder('//Alice', keyringType),
213
+ bob: polkadotSignerBuilder('//Bob', keyringType),
214
+ charlie: polkadotSignerBuilder('//Charlie', keyringType),
215
+ dave: polkadotSignerBuilder('//Dave', keyringType),
216
+ eve: polkadotSignerBuilder('//Eve', keyringType),
217
+ ferdie: polkadotSignerBuilder('//Ferdie', keyringType),
218
+ polkadotSignerBuilder
219
+ };
220
+ };
@@ -1,6 +1,6 @@
1
- import { ApiPromise } from '@polkadot/api';
2
- import { GenericExtrinsic } from '@polkadot/types';
3
- import { SignatureOptions } from '@polkadot/types/types';
1
+ import type { ApiPromise } from '@polkadot/api';
2
+ import type { GenericExtrinsic } from '@polkadot/types';
3
+ import type { SignatureOptions } from '@polkadot/types/types';
4
4
  export type SignFakeOptions = Partial<SignatureOptions>;
5
5
  export declare const signFakeWithApi: (api: ApiPromise, tx: GenericExtrinsic, addr: string, options?: SignFakeOptions) => Promise<void>;
6
6
  export declare const signFake: (tx: GenericExtrinsic, addr: string, options: SignatureOptions) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks-utils",
3
- "version": "1.0.2-2",
3
+ "version": "1.0.3",
4
4
  "author": "Acala Developers <hello@acala.network>",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -13,18 +13,21 @@
13
13
  "depcheck": "npx depcheck"
14
14
  },
15
15
  "dependencies": {
16
- "@acala-network/chopsticks": "1.0.2-2",
17
- "@acala-network/chopsticks-core": "1.0.2-2",
18
- "@polkadot/api": "^15.0",
19
- "@polkadot/api-base": "^15.0",
20
- "@polkadot/keyring": "^13.2",
21
- "@polkadot/types": "^15.0",
22
- "@polkadot/util": "^13.2"
16
+ "@acala-network/chopsticks": "1.0.3",
17
+ "@acala-network/chopsticks-core": "1.0.3",
18
+ "@polkadot-labs/hdkd": "^0.0.11",
19
+ "@polkadot-labs/hdkd-helpers": "^0.0.11",
20
+ "@polkadot/api": "^15.7.1",
21
+ "@polkadot/api-base": "^15.7.1",
22
+ "@polkadot/keyring": "^13.4.3",
23
+ "@polkadot/types": "^15.7.1",
24
+ "@polkadot/util": "^13.4.3",
25
+ "polkadot-api": "^1.9.2"
23
26
  },
24
27
  "devDependencies": {
25
- "@swc/cli": "0.5.2",
26
- "@swc/core": "^1.10.1",
27
- "typescript": "^5.7.2"
28
+ "@swc/cli": "0.6.0",
29
+ "@swc/core": "^1.11.1",
30
+ "typescript": "^5.7.3"
28
31
  },
29
32
  "files": [
30
33
  "dist/esm/**",