@palliora.org/chainsdk 0.3.1 → 0.3.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.
package/dist/index.js CHANGED
@@ -1,3 +1,14 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
4
+ };
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
+
1
12
  // src/account/account.ts
2
13
  import { waitReady } from "@polkadot/wasm-crypto";
3
14
 
@@ -21,7 +32,9 @@ var AccountSourceType = /* @__PURE__ */ ((AccountSourceType2) => {
21
32
  import { Keyring } from "@polkadot/api";
22
33
  import { hexToU8a } from "@polkadot/util";
23
34
  import { ed25519PairFromSecret, secp256k1PairFromSeed } from "@polkadot/util-crypto";
24
- async function createAccount(input, type, name = "default", cryptoType = "sr25519" /* SR25519 */) {
35
+ import { keccak256 } from "viem";
36
+ import { poseidon1, poseidon2 } from "poseidon-lite";
37
+ async function createAccount(input, type, name = "default", cryptoType = "sr25519" /* SR25519 */, signedMsg = "sign") {
25
38
  await waitReady();
26
39
  const keyring2 = new Keyring({ type: cryptoType });
27
40
  switch (type) {
@@ -48,6 +61,12 @@ async function createAccount(input, type, name = "default", cryptoType = "sr2551
48
61
  cryptoType
49
62
  );
50
63
  return account;
64
+ case "derived" /* DERIVED */:
65
+ if (!input.startsWith("0x")) {
66
+ throw new Error("Invalid signature format for derived account. Expected hex string starting with 0x.");
67
+ }
68
+ const signKeyBytes = sigToSeed(signedMsg, input);
69
+ return createAccount(signKeyBytes, "seed" /* SEED */, name, cryptoType);
51
70
  default:
52
71
  throw new Error("Invalid input type");
53
72
  }
@@ -83,6 +102,15 @@ function pairFromPrivateKeyHex(privateKeyHex, cryptoType) {
83
102
  throw new Error(`Unsupported crypto type: ${cryptoType}`);
84
103
  }
85
104
  }
105
+ function sigToSeed(msg, sign) {
106
+ const seed = BigInt(keccak256(sign));
107
+ const encoder = new TextEncoder();
108
+ const signBytes = encoder.encode(msg);
109
+ const signHex = Array.from(signBytes).map((b) => b.toString(16).padStart(2, "0")).join("");
110
+ const SALT_SIGN = poseidon1([BigInt(`0x${signHex}`)]);
111
+ const signKeyBytes = poseidon2([seed.toString(), SALT_SIGN]).toString(16).slice(0, 64);
112
+ return signKeyBytes;
113
+ }
86
114
 
87
115
  // src/chain/spec.ts
88
116
  var API_RPC = {
@@ -175,7 +203,7 @@ var API_TYPES = {
175
203
  },
176
204
  GuardianNwParams: {
177
205
  kzg: "Vec<u8>",
178
- agg_key: "Vec<u8>"
206
+ aggKey: "Vec<u8>"
179
207
  },
180
208
  AppId: "Compact<u32>",
181
209
  DataLookupItem: {
@@ -226,9 +254,9 @@ var API_TYPES = {
226
254
  verifier: "u128"
227
255
  },
228
256
  SilentThresholdParams: {
229
- td_params: "Vec<u8>",
230
- pk_bytes: "Vec<u8>",
231
- tau_params: "Vec<u8>"
257
+ tdParams: "Vec<u8>",
258
+ pkBytes: "Vec<u8>",
259
+ tauParams: "Vec<u8>"
232
260
  },
233
261
  ThresholdParams: {
234
262
  _enum: {
@@ -254,16 +282,16 @@ var API_TYPES = {
254
282
  }
255
283
  },
256
284
  Secp256k1Params: {
257
- recipient_public_key: "Vec<u8>",
258
- ephemeral_public_key: "Option<Vec<u8>>",
285
+ recipientPublicKey: "Vec<u8>",
286
+ ephemeralPublicKey: "Option<Vec<u8>>",
259
287
  compressed: "bool",
260
288
  kdf: "KdfParams",
261
289
  salt: "Option<Vec<u8>>",
262
290
  info: "Option<Vec<u8>>"
263
291
  },
264
292
  Ed25519Params: {
265
- recipient_public_key: "Vec<u8>",
266
- ephemeral_public_key: "Option<Vec<u8>>",
293
+ recipientPublicKey: "Vec<u8>",
294
+ ephemeralPublicKey: "Option<Vec<u8>>",
267
295
  kdf: "KdfParams",
268
296
  salt: "Option<Vec<u8>>",
269
297
  info: "Option<Vec<u8>>"
@@ -275,12 +303,12 @@ var API_TYPES = {
275
303
  }
276
304
  },
277
305
  ThresholdHybridParams: {
278
- threshold_params: "ThresholdParams",
279
- symmetric_params: "SymmetricParams"
306
+ thresholdParams: "ThresholdParams",
307
+ symmetricParams: "SymmetricParams"
280
308
  },
281
309
  AsymmetricHybridParams: {
282
- asymmetric_params: "AsymmetricParams",
283
- symmetric_params: "SymmetricParams"
310
+ asymmetricParams: "AsymmetricParams",
311
+ symmetricParams: "SymmetricParams"
284
312
  },
285
313
  CipherSuite: {
286
314
  _enum: {
@@ -298,7 +326,7 @@ var API_TYPES = {
298
326
  }
299
327
  },
300
328
  NativeExecuteDA: {
301
- _enum: ["Inference"]
329
+ _enum: ["Inference", "ContractAccess"]
302
330
  },
303
331
  NativeDataDA: {
304
332
  _enum: ["DaFalse", "DaTrue"]
@@ -307,8 +335,11 @@ var API_TYPES = {
307
335
  data: "Vec<u8>"
308
336
  },
309
337
  DAInputChainTransaction: {
310
- block_number: "u64",
311
- extrinsic_index: "u32"
338
+ blockNumber: "u64",
339
+ extrinsicIndex: "u32"
340
+ },
341
+ DAInputContractId: {
342
+ id: "[u8; 32]"
312
343
  },
313
344
  DAInputIpfs: {
314
345
  cid: "Vec<u8>",
@@ -324,6 +355,7 @@ var API_TYPES = {
324
355
  Null: "Null",
325
356
  Inline: "DAInputInline",
326
357
  ChainTransaction: "DAInputChainTransaction",
358
+ ContractId: "DAInputContractId",
327
359
  Ipfs: "DAInputIpfs",
328
360
  Url: "DAInputUrl",
329
361
  NativeExecute: "NativeExecuteDA",
@@ -333,7 +365,8 @@ var API_TYPES = {
333
365
  ContractType: {
334
366
  _enum: {
335
367
  Dormant: "Null",
336
- Active: "Null"
368
+ Active: "Null",
369
+ Subscription: "Null"
337
370
  }
338
371
  },
339
372
  StoreType: {
@@ -347,28 +380,29 @@ var API_TYPES = {
347
380
  ComputeMetadata: {
348
381
  name: "Vec<u8>",
349
382
  description: "Vec<u8>",
350
- store_type: "StoreType",
351
- group_id: "H256"
383
+ storeType: "StoreType",
384
+ groupId: "H256"
352
385
  },
353
386
  ComputeInfo: {
354
387
  cipher: "CipherSuite",
355
- computer_indices: "Vec<u32>",
388
+ computerIndices: "Vec<u32>",
356
389
  fees: "u128",
390
+ computeRate: "u128",
357
391
  deadline: "u64",
358
392
  confidentiality: "ConfidentialityLevel",
359
- fee_function: "Option<u8>",
360
- program_env: "Option<Vec<u8>>",
393
+ feeFunction: "Option<u8>",
394
+ programEnv: "Option<Vec<u8>>",
361
395
  input: "DAInput",
362
396
  program: "DAInput",
363
397
  metadata: "Option<ComputeMetadata>"
364
398
  },
365
399
  Contract: {
366
- contract_type: "ContractType",
400
+ contractType: "ContractType",
367
401
  guardians: "Vec<AccountId>",
368
- pre_check: "Option<ComputeInfo>",
402
+ preCheck: "Option<ComputeInfo>",
369
403
  compute: "ComputeInfo",
370
- post_check: "Option<ComputeInfo>",
371
- result_cipher: "CipherSuite"
404
+ postCheck: "Option<ComputeInfo>",
405
+ resultCipher: "CipherSuite"
372
406
  },
373
407
  AgreementInfo: {
374
408
  status: "AgreementStatus",
@@ -376,7 +410,7 @@ var API_TYPES = {
376
410
  index: "u32"
377
411
  },
378
412
  ComputePayload: {
379
- da_type: "u8",
413
+ daType: "u8",
380
414
  agreement: "Option<BoundedVec<[u8; 32], 10>>",
381
415
  verification: "u8",
382
416
  compute: "u8"
@@ -452,10 +486,46 @@ var API_TYPES = {
452
486
  GRawScalar: "U256",
453
487
  GProof: "[u8; 48]",
454
488
  GRow: "Vec<GRawScalar>",
455
- GDataProof: "(GRawScalar, GProof)"
489
+ GDataProof: "(GRawScalar, GProof)",
490
+ AgreementStatus: {
491
+ _enum: ["NotFound", "Pending", "Accepted", "Rejected", "Settled"]
492
+ },
493
+ AcceptedSubStatus: {
494
+ _enum: ["Running", "AwaitingTopUp", "TopUpReceived", "RejectedInsufficientBudget", "RejectedRateMismatch"]
495
+ },
496
+ RejectedSubStatus: {
497
+ _enum: ["InsufficientBudget", "RateMismatch"]
498
+ },
499
+ SettlementReason: {
500
+ _enum: ["ResultReceived", "DeadlineReached", "BudgetExhausted"]
501
+ },
502
+ ExecutionOutcome: {
503
+ _enum: ["FullSettlement", "PartialSettlement", "Success", "Failed", "Terminated", "TopUpTimeout"]
504
+ },
505
+ ContractInfo: {
506
+ status: "AgreementStatus",
507
+ owner: "AccountId",
508
+ originBlock: "u32",
509
+ invocationBlock: "u32",
510
+ index: "u32",
511
+ usagePrice: "u128",
512
+ contractType: "ContractType"
513
+ },
514
+ SettlementInfo: {
515
+ computeRate: "u128",
516
+ inputContractId: "Option<[u8; 32]>",
517
+ guardians: "Vec<AccountId>"
518
+ },
519
+ AppKeyInfo: {
520
+ owner: "AccountId",
521
+ id: "AppId"
522
+ },
523
+ DataType: {
524
+ _enum: ["Dataset", "Model", "Agent"]
525
+ }
456
526
  };
457
- var DEFAULT_COMPUTE_PAYLOAD = { compute: { da_type: 0, verification: 0, compute: 0 } };
458
- var DEFAULT_EMPTY_PAYLOAD = { compute: { da_type: 0, verification: 0, compute: 0, agreement: [] } };
527
+ var DEFAULT_COMPUTE_PAYLOAD = { compute: { daType: 0, verification: 0, compute: 0 } };
528
+ var DEFAULT_EMPTY_PAYLOAD = { compute: { daType: 0, verification: 0, compute: 0, agreement: [] } };
459
529
  var API_EXTENSIONS = {
460
530
  CheckAppId: {
461
531
  extrinsic: {
@@ -1487,15 +1557,21 @@ var FileFromMetadataRef = async (mcryptApi, metadataRef) => {
1487
1557
  };
1488
1558
 
1489
1559
  // src/compute/agreement.ts
1490
- async function createAgreement(contract, account) {
1560
+ function buildFee(fee) {
1561
+ return {
1562
+ fees: toAtomicPaliAmount(fee?.amount ?? "0"),
1563
+ computeRate: toAtomicPaliAmount(fee?.computeRate ?? "0")
1564
+ };
1565
+ }
1566
+ async function createAgreement(contract, account, oracle_quore_id = void 0) {
1491
1567
  const api2 = await getApi();
1492
1568
  if (!api2) throw new Error("Api not initialized");
1493
- const tx = api2.tx["compute"]["agreement"](contract);
1569
+ const tx = api2.tx["compute"]["agreement"](contract, oracle_quore_id ?? null);
1494
1570
  const opts = {
1495
1571
  compute: {
1496
- da_type: 1,
1572
+ daType: 1,
1497
1573
  verification: 0,
1498
- compute: contract.contract_type === "Active" ? 1 : 0
1574
+ compute: contract.contractType === "Active" ? 1 : 0
1499
1575
  }
1500
1576
  };
1501
1577
  const { tx_result, blockNumber, index, hash } = await signAndSend(
@@ -1527,22 +1603,22 @@ async function createSimpleAgreement() {
1527
1603
  const guardianIds = (await getGuardianAddress()).slice(0, 3).map((g) => g.address);
1528
1604
  assert(guardianIds.length === 3, "Not enough guardians to create agreement");
1529
1605
  const contract = {
1530
- contract_type: "Dormant",
1606
+ contractType: "Dormant",
1531
1607
  guardians: guardianIds,
1532
- pre_check: null,
1608
+ preCheck: null,
1533
1609
  compute: {
1534
1610
  cipher: "Plaintext",
1535
- computer_indices: [0, 1, 2],
1536
- fees: toAtomicPaliAmount("0.01"),
1611
+ computerIndices: [0, 1, 2],
1612
+ ...buildFee({ amount: "0", computeRate: "0" }),
1537
1613
  deadline: 0,
1538
1614
  confidentiality: { Trusted: 0 },
1539
- fee_function: null,
1615
+ feeFunction: null,
1540
1616
  input: null,
1541
1617
  program: { NativeData: "DaFalse" },
1542
1618
  metadata: null
1543
1619
  },
1544
- post_check: null,
1545
- result_cipher: "Plaintext"
1620
+ postCheck: null,
1621
+ resultCipher: "Plaintext"
1546
1622
  };
1547
1623
  const keyring2 = await getKeyring();
1548
1624
  const account = keyring2.getPairs()[0];
@@ -1552,14 +1628,13 @@ async function createSimpleAgreement() {
1552
1628
  // src/compute/data.ts
1553
1629
  async function dataContract(params, account) {
1554
1630
  const plaintextCipher = "Plaintext";
1555
- const atomicFees = toAtomicPaliAmount(params.fees ?? "0");
1556
1631
  const computeStep = {
1557
1632
  cipher: plaintextCipher,
1558
- computer_indices: params.guardians.map((_, i) => i),
1559
- fees: atomicFees,
1633
+ computerIndices: params.guardians.map((_, i) => i),
1634
+ ...buildFee(params.fee),
1560
1635
  deadline: params.deadline ?? 0,
1561
1636
  confidentiality: { Trusted: params.trustIndex ?? 0 },
1562
- fee_function: null,
1637
+ feeFunction: null,
1563
1638
  input: {
1564
1639
  Url: {
1565
1640
  url: Array.from(new TextEncoder().encode(params.url))
@@ -1570,12 +1645,12 @@ async function dataContract(params, account) {
1570
1645
  }
1571
1646
  };
1572
1647
  const contract = {
1573
- contract_type: "Dormant",
1648
+ contractType: "Dormant",
1574
1649
  guardians: params.guardians,
1575
- pre_check: null,
1650
+ preCheck: null,
1576
1651
  compute: computeStep,
1577
- post_check: null,
1578
- result_cipher: plaintextCipher
1652
+ postCheck: null,
1653
+ resultCipher: plaintextCipher
1579
1654
  };
1580
1655
  return createAgreement(contract, account);
1581
1656
  }
@@ -1583,23 +1658,22 @@ async function dataContract(params, account) {
1583
1658
  // src/compute/inference.ts
1584
1659
  async function inferenceCompute(params, account) {
1585
1660
  const inputData = typeof params.input === "string" ? Array.from(new TextEncoder().encode(params.input)) : Array.from(params.input);
1586
- const atomicFees = toAtomicPaliAmount(params.fees ?? "0");
1587
1661
  const plaintextCipher = "Plaintext";
1588
1662
  const computeStep = {
1589
1663
  cipher: plaintextCipher,
1590
- computer_indices: params.guardians.map((_, i) => i),
1591
- fees: atomicFees,
1664
+ computerIndices: params.guardians.map((_, i) => i),
1665
+ ...buildFee(params.fee),
1592
1666
  deadline: params.deadline ?? 0,
1593
1667
  confidentiality: { Trusted: 0 },
1594
- fee_function: null,
1668
+ feeFunction: null,
1595
1669
  input: { Inline: { data: inputData } },
1596
1670
  program: { NativeExecute: "Inference" }
1597
1671
  };
1598
1672
  const contract = {
1599
- contract_type: "Active",
1673
+ contractType: "Active",
1600
1674
  guardians: params.guardians,
1601
1675
  compute: computeStep,
1602
- result_cipher: plaintextCipher
1676
+ resultCipher: plaintextCipher
1603
1677
  };
1604
1678
  return createAgreement(contract, account);
1605
1679
  }
@@ -1670,14 +1744,13 @@ async function getGuardianParticipants() {
1670
1744
  // src/compute/simple.ts
1671
1745
  async function simpleCompute(params, account) {
1672
1746
  const plaintextCipher = "Plaintext";
1673
- const atomicFees = toAtomicPaliAmount(params.fees ?? "0");
1674
1747
  const computeStep = {
1675
1748
  cipher: plaintextCipher,
1676
- computer_indices: params.guardians.map((_, i) => i),
1677
- fees: atomicFees,
1749
+ computerIndices: params.guardians.map((_, i) => i),
1750
+ ...buildFee(params.fee),
1678
1751
  deadline: params.deadline ?? 0,
1679
1752
  confidentiality: { Trusted: params.trustIndex ?? 0 },
1680
- fee_function: null,
1753
+ feeFunction: null,
1681
1754
  input: null,
1682
1755
  program: {
1683
1756
  Url: {
@@ -1686,12 +1759,12 @@ async function simpleCompute(params, account) {
1686
1759
  }
1687
1760
  };
1688
1761
  const contract = {
1689
- contract_type: "Active",
1762
+ contractType: "Active",
1690
1763
  guardians: params.guardians,
1691
- pre_check: null,
1764
+ preCheck: null,
1692
1765
  compute: computeStep,
1693
- post_check: null,
1694
- result_cipher: plaintextCipher
1766
+ postCheck: null,
1767
+ resultCipher: plaintextCipher
1695
1768
  };
1696
1769
  return createAgreement(contract, account);
1697
1770
  }
@@ -1734,7 +1807,7 @@ async function writeMetadata(account, name, description, ref, price, dataType, l
1734
1807
  }
1735
1808
  async function registerDataAgreement(account, params) {
1736
1809
  debugLog(
1737
- `Registering data agreement for DA ref ${params.ref.blockNumber}-${params.ref.index} at ${formatPaliAmount(params.fees)}`
1810
+ `Registering data agreement for DA ref ${params.ref.blockNumber}-${params.ref.index} at ${formatPaliAmount(toAtomicPaliAmount(params.fee.amount ?? "0"))}`
1738
1811
  );
1739
1812
  const cipher = params.cipher ?? "Plaintext";
1740
1813
  const resultCipher = params.resultCipher ?? "Plaintext";
@@ -1742,20 +1815,20 @@ async function registerDataAgreement(account, params) {
1742
1815
  const computeMetadata = params.metadata ? {
1743
1816
  name: Array.from(encoder.encode(params.metadata.name)),
1744
1817
  description: Array.from(encoder.encode(params.metadata.description)),
1745
- store_type: params.metadata.storeType,
1746
- group_id: params.metadata.groupId
1818
+ storeType: params.metadata.storeType,
1819
+ groupId: params.metadata.groupId
1747
1820
  } : null;
1748
1821
  const computeStep = {
1749
1822
  cipher,
1750
- computer_indices: params.guardians.map((_, i) => i),
1751
- fees: params.fees,
1823
+ computerIndices: params.guardians.map((_, i) => i),
1824
+ ...buildFee(params.fee),
1752
1825
  deadline: params.deadline ?? 0,
1753
1826
  confidentiality: { Trusted: params.trustIndex ?? 0 },
1754
- fee_function: null,
1827
+ feeFunction: null,
1755
1828
  input: {
1756
1829
  ChainTransaction: {
1757
- block_number: params.ref.blockNumber,
1758
- extrinsic_index: params.ref.index
1830
+ blockNumber: params.ref.blockNumber,
1831
+ extrinsicIndex: params.ref.index
1759
1832
  }
1760
1833
  },
1761
1834
  program: {
@@ -1764,12 +1837,12 @@ async function registerDataAgreement(account, params) {
1764
1837
  metadata: computeMetadata
1765
1838
  };
1766
1839
  const contract = {
1767
- contract_type: "Dormant",
1840
+ contractType: "Dormant",
1768
1841
  guardians: params.guardians,
1769
- pre_check: null,
1842
+ preCheck: null,
1770
1843
  compute: computeStep,
1771
- post_check: null,
1772
- result_cipher: resultCipher
1844
+ postCheck: null,
1845
+ resultCipher
1773
1846
  };
1774
1847
  return createAgreement(contract, account);
1775
1848
  }
@@ -1794,7 +1867,7 @@ async function runAgent(account, agentRef, nonce, ciphertext, tdParams, pkBytes,
1794
1867
  );
1795
1868
  const opts = {
1796
1869
  compute: {
1797
- da_type: 4,
1870
+ daType: 4,
1798
1871
  verification: 0,
1799
1872
  compute: 1,
1800
1873
  agreement: [agreementId]
@@ -1853,14 +1926,14 @@ async function submitTEDataWithCipher(account, data, chosenGuardians, tau_params
1853
1926
  ref,
1854
1927
  cipher: {
1855
1928
  ThresholdHybrid: {
1856
- threshold_params: {
1929
+ thresholdParams: {
1857
1930
  SilentThreshold: {
1858
- td_params: Array.from(hexToUint8Array(encryptedKey)),
1859
- pk_bytes: Array.from(hexToUint8Array(group_pk)),
1860
- tau_params: Array.from(hexToUint8Array(tau_params))
1931
+ tdParams: Array.from(hexToUint8Array(encryptedKey)),
1932
+ pkBytes: Array.from(hexToUint8Array(group_pk)),
1933
+ tauParams: Array.from(hexToUint8Array(tau_params))
1861
1934
  }
1862
1935
  },
1863
- symmetric_params: {
1936
+ symmetricParams: {
1864
1937
  ChaCha20Poly1305: { nonce: Array.from(nonce) }
1865
1938
  }
1866
1939
  }
@@ -1879,7 +1952,6 @@ async function uploadData(options) {
1879
1952
  );
1880
1953
  console.log("Guardian group info:", guardianGroupInfo);
1881
1954
  const account = (await getKeyring()).pairs[0];
1882
- const atomicPrice = toAtomicPaliAmount(price);
1883
1955
  if (filePath) {
1884
1956
  throw new Error("uploadData: file path upload is not implemented");
1885
1957
  } else {
@@ -1895,7 +1967,7 @@ async function uploadData(options) {
1895
1967
  await registerDataAgreement(account, {
1896
1968
  ref: dataRef,
1897
1969
  guardians: guardianGroupInfo.guardians,
1898
- fees: atomicPrice,
1970
+ fee: { amount: price },
1899
1971
  cipher,
1900
1972
  metadata: {
1901
1973
  name,
@@ -2115,6 +2187,464 @@ export * from "@polkadot/util";
2115
2187
  import * as utilCrypto from "@polkadot/util-crypto";
2116
2188
  import * as wasmCrypto from "@polkadot/wasm-crypto";
2117
2189
  import { ApiPromise as ApiPromise2, WsProvider as WsProvider3, HttpProvider } from "@polkadot/api";
2190
+
2191
+ // node_modules/.pnpm/@polkadot+keyring@13.5.9_@polkadot+util-crypto@13.5.9_@polkadot+util@13.5.9__@polkadot+util@13.5.9/node_modules/@polkadot/keyring/bundle.js
2192
+ import { decodeAddress as decodeAddress3, encodeAddress as encodeAddress2, setSS58Format } from "@polkadot/util-crypto";
2193
+
2194
+ // node_modules/.pnpm/@polkadot+keyring@13.5.9_@polkadot+util-crypto@13.5.9_@polkadot+util@13.5.9__@polkadot+util@13.5.9/node_modules/@polkadot/keyring/keyring.js
2195
+ import { hexToU8a as hexToU8a2, isHex as isHex2, stringToU8a } from "@polkadot/util";
2196
+ import { base64Decode, decodeAddress as decodeAddress2, ed25519PairFromSeed as ed25519FromSeed2, encodeAddress, ethereumEncode as ethereumEncode2, hdEthereum, keyExtractSuri, keyFromPath as keyFromPath2, mnemonicToLegacySeed, mnemonicToMiniSecret, secp256k1PairFromSeed as secp256k1FromSeed2, sr25519PairFromSeed as sr25519FromSeed2 } from "@polkadot/util-crypto";
2197
+
2198
+ // node_modules/.pnpm/@polkadot+keyring@13.5.9_@polkadot+util-crypto@13.5.9_@polkadot+util@13.5.9__@polkadot+util@13.5.9/node_modules/@polkadot/keyring/pair/index.js
2199
+ import { objectSpread as objectSpread2, u8aConcat as u8aConcat2, u8aEmpty, u8aEq as u8aEq2, u8aToHex, u8aToU8a } from "@polkadot/util";
2200
+ import { blake2AsU8a, ed25519PairFromSeed as ed25519FromSeed, ed25519Sign, ethereumEncode, keccakAsU8a, keyExtractPath, keyFromPath, secp256k1Compress, secp256k1Expand, secp256k1PairFromSeed as secp256k1FromSeed, secp256k1Sign, signatureVerify, sr25519PairFromSeed as sr25519FromSeed, sr25519Sign, sr25519VrfSign, sr25519VrfVerify } from "@polkadot/util-crypto";
2201
+
2202
+ // node_modules/.pnpm/@polkadot+keyring@13.5.9_@polkadot+util-crypto@13.5.9_@polkadot+util@13.5.9__@polkadot+util@13.5.9/node_modules/@polkadot/keyring/pair/decode.js
2203
+ import { u8aEq } from "@polkadot/util";
2204
+ import { jsonDecryptData } from "@polkadot/util-crypto";
2205
+
2206
+ // node_modules/.pnpm/@polkadot+keyring@13.5.9_@polkadot+util-crypto@13.5.9_@polkadot+util@13.5.9__@polkadot+util@13.5.9/node_modules/@polkadot/keyring/pair/defaults.js
2207
+ var PAIR_DIV = new Uint8Array([161, 35, 3, 33, 0]);
2208
+ var PAIR_HDR = new Uint8Array([48, 83, 2, 1, 1, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32]);
2209
+ var PUB_LENGTH = 32;
2210
+ var SEC_LENGTH = 64;
2211
+ var SEED_LENGTH = 32;
2212
+
2213
+ // node_modules/.pnpm/@polkadot+keyring@13.5.9_@polkadot+util-crypto@13.5.9_@polkadot+util@13.5.9__@polkadot+util@13.5.9/node_modules/@polkadot/keyring/pair/decode.js
2214
+ var SEED_OFFSET = PAIR_HDR.length;
2215
+ function decodePair(passphrase, encrypted, _encType) {
2216
+ const encType = Array.isArray(_encType) || _encType === void 0 ? _encType : [_encType];
2217
+ const decrypted = jsonDecryptData(encrypted, passphrase, encType);
2218
+ const header = decrypted.subarray(0, PAIR_HDR.length);
2219
+ if (!u8aEq(header, PAIR_HDR)) {
2220
+ throw new Error("Invalid encoding header found in body");
2221
+ }
2222
+ let secretKey = decrypted.subarray(SEED_OFFSET, SEED_OFFSET + SEC_LENGTH);
2223
+ let divOffset = SEED_OFFSET + SEC_LENGTH;
2224
+ let divider = decrypted.subarray(divOffset, divOffset + PAIR_DIV.length);
2225
+ if (!u8aEq(divider, PAIR_DIV)) {
2226
+ divOffset = SEED_OFFSET + SEED_LENGTH;
2227
+ secretKey = decrypted.subarray(SEED_OFFSET, divOffset);
2228
+ divider = decrypted.subarray(divOffset, divOffset + PAIR_DIV.length);
2229
+ if (!u8aEq(divider, PAIR_DIV)) {
2230
+ throw new Error("Invalid encoding divider found in body");
2231
+ }
2232
+ }
2233
+ const pubOffset = divOffset + PAIR_DIV.length;
2234
+ const publicKey = decrypted.subarray(pubOffset, pubOffset + PUB_LENGTH);
2235
+ return {
2236
+ publicKey,
2237
+ secretKey
2238
+ };
2239
+ }
2240
+
2241
+ // node_modules/.pnpm/@polkadot+keyring@13.5.9_@polkadot+util-crypto@13.5.9_@polkadot+util@13.5.9__@polkadot+util@13.5.9/node_modules/@polkadot/keyring/pair/encode.js
2242
+ import { u8aConcat } from "@polkadot/util";
2243
+ import { naclEncrypt, scryptEncode, scryptToU8a } from "@polkadot/util-crypto";
2244
+ function encodePair({ publicKey, secretKey }, passphrase) {
2245
+ if (!secretKey) {
2246
+ throw new Error("Expected a valid secretKey to be passed to encode");
2247
+ }
2248
+ const encoded = u8aConcat(PAIR_HDR, secretKey, PAIR_DIV, publicKey);
2249
+ if (!passphrase) {
2250
+ return encoded;
2251
+ }
2252
+ const { params, password, salt } = scryptEncode(passphrase);
2253
+ const { encrypted, nonce } = naclEncrypt(encoded, password.subarray(0, 32));
2254
+ return u8aConcat(scryptToU8a(salt, params), nonce, encrypted);
2255
+ }
2256
+
2257
+ // node_modules/.pnpm/@polkadot+keyring@13.5.9_@polkadot+util-crypto@13.5.9_@polkadot+util@13.5.9__@polkadot+util@13.5.9/node_modules/@polkadot/keyring/pair/toJson.js
2258
+ import { objectSpread } from "@polkadot/util";
2259
+ import { jsonEncryptFormat } from "@polkadot/util-crypto";
2260
+ function pairToJson(type, { address, meta }, encoded, isEncrypted) {
2261
+ return objectSpread(jsonEncryptFormat(encoded, ["pkcs8", type], isEncrypted), {
2262
+ address,
2263
+ meta
2264
+ });
2265
+ }
2266
+
2267
+ // node_modules/.pnpm/@polkadot+keyring@13.5.9_@polkadot+util-crypto@13.5.9_@polkadot+util@13.5.9__@polkadot+util@13.5.9/node_modules/@polkadot/keyring/pair/index.js
2268
+ var SIG_TYPE_NONE = new Uint8Array();
2269
+ var TYPE_FROM_SEED = {
2270
+ ecdsa: secp256k1FromSeed,
2271
+ ed25519: ed25519FromSeed,
2272
+ ethereum: secp256k1FromSeed,
2273
+ sr25519: sr25519FromSeed
2274
+ };
2275
+ var TYPE_PREFIX = {
2276
+ ecdsa: new Uint8Array([2]),
2277
+ ed25519: new Uint8Array([0]),
2278
+ ethereum: new Uint8Array([2]),
2279
+ sr25519: new Uint8Array([1])
2280
+ };
2281
+ var TYPE_SIGNATURE = {
2282
+ ecdsa: (m, p) => secp256k1Sign(m, p, "blake2"),
2283
+ ed25519: ed25519Sign,
2284
+ ethereum: (m, p) => secp256k1Sign(m, p, "keccak"),
2285
+ sr25519: sr25519Sign
2286
+ };
2287
+ var TYPE_ADDRESS = {
2288
+ ecdsa: (p) => p.length > 32 ? blake2AsU8a(p) : p,
2289
+ ed25519: (p) => p,
2290
+ ethereum: (p) => p.length === 20 ? p : keccakAsU8a(secp256k1Expand(p)),
2291
+ sr25519: (p) => p
2292
+ };
2293
+ function isLocked(secretKey) {
2294
+ return !secretKey || u8aEmpty(secretKey);
2295
+ }
2296
+ function vrfHash(proof, context, extra) {
2297
+ return blake2AsU8a(u8aConcat2(context || "", extra || "", proof));
2298
+ }
2299
+ function createPair({ toSS58, type }, { publicKey, secretKey }, meta = {}, encoded = null, encTypes) {
2300
+ const decodePkcs8 = (passphrase, userEncoded) => {
2301
+ const decoded = decodePair(passphrase, userEncoded || encoded, encTypes);
2302
+ if (decoded.secretKey.length === 64) {
2303
+ publicKey = decoded.publicKey;
2304
+ secretKey = decoded.secretKey;
2305
+ } else {
2306
+ const pair = TYPE_FROM_SEED[type](decoded.secretKey);
2307
+ publicKey = pair.publicKey;
2308
+ secretKey = pair.secretKey;
2309
+ }
2310
+ };
2311
+ const recode = (passphrase) => {
2312
+ isLocked(secretKey) && encoded && decodePkcs8(passphrase, encoded);
2313
+ encoded = encodePair({ publicKey, secretKey }, passphrase);
2314
+ encTypes = void 0;
2315
+ return encoded;
2316
+ };
2317
+ const encodeAddress3 = () => {
2318
+ const raw = TYPE_ADDRESS[type](publicKey);
2319
+ return type === "ethereum" ? ethereumEncode(raw) : toSS58(raw);
2320
+ };
2321
+ return {
2322
+ get address() {
2323
+ return encodeAddress3();
2324
+ },
2325
+ get addressRaw() {
2326
+ const raw = TYPE_ADDRESS[type](publicKey);
2327
+ return type === "ethereum" ? raw.slice(-20) : raw;
2328
+ },
2329
+ get isLocked() {
2330
+ return isLocked(secretKey);
2331
+ },
2332
+ get meta() {
2333
+ return meta;
2334
+ },
2335
+ get publicKey() {
2336
+ return publicKey;
2337
+ },
2338
+ get type() {
2339
+ return type;
2340
+ },
2341
+ // eslint-disable-next-line sort-keys
2342
+ decodePkcs8,
2343
+ derive: (suri, meta2) => {
2344
+ if (type === "ethereum") {
2345
+ throw new Error("Unable to derive on this keypair");
2346
+ } else if (isLocked(secretKey)) {
2347
+ throw new Error("Cannot derive on a locked keypair");
2348
+ }
2349
+ const { path: path2 } = keyExtractPath(suri);
2350
+ const derived = keyFromPath({ publicKey, secretKey }, path2, type);
2351
+ return createPair({ toSS58, type }, derived, meta2, null);
2352
+ },
2353
+ encodePkcs8: (passphrase) => {
2354
+ return recode(passphrase);
2355
+ },
2356
+ lock: () => {
2357
+ secretKey = new Uint8Array();
2358
+ },
2359
+ setMeta: (additional) => {
2360
+ meta = objectSpread2({}, meta, additional);
2361
+ },
2362
+ sign: (message, options = {}) => {
2363
+ if (isLocked(secretKey)) {
2364
+ throw new Error("Cannot sign with a locked key pair");
2365
+ }
2366
+ return u8aConcat2(options.withType ? TYPE_PREFIX[type] : SIG_TYPE_NONE, TYPE_SIGNATURE[type](u8aToU8a(message), { publicKey, secretKey }));
2367
+ },
2368
+ toJson: (passphrase) => {
2369
+ const address = ["ecdsa", "ethereum"].includes(type) ? publicKey.length === 20 ? u8aToHex(publicKey) : u8aToHex(secp256k1Compress(publicKey)) : encodeAddress3();
2370
+ return pairToJson(type, { address, meta }, recode(passphrase), !!passphrase);
2371
+ },
2372
+ unlock: (passphrase) => {
2373
+ return decodePkcs8(passphrase);
2374
+ },
2375
+ verify: (message, signature, signerPublic) => {
2376
+ return signatureVerify(message, signature, TYPE_ADDRESS[type](u8aToU8a(signerPublic))).isValid;
2377
+ },
2378
+ vrfSign: (message, context, extra) => {
2379
+ if (isLocked(secretKey)) {
2380
+ throw new Error("Cannot sign with a locked key pair");
2381
+ }
2382
+ if (type === "sr25519") {
2383
+ return sr25519VrfSign(message, { secretKey }, context, extra);
2384
+ }
2385
+ const proof = TYPE_SIGNATURE[type](u8aToU8a(message), { publicKey, secretKey });
2386
+ return u8aConcat2(vrfHash(proof, context, extra), proof);
2387
+ },
2388
+ vrfVerify: (message, vrfResult, signerPublic, context, extra) => {
2389
+ if (type === "sr25519") {
2390
+ return sr25519VrfVerify(message, vrfResult, publicKey, context, extra);
2391
+ }
2392
+ const result = signatureVerify(message, u8aConcat2(TYPE_PREFIX[type], vrfResult.subarray(32)), TYPE_ADDRESS[type](u8aToU8a(signerPublic)));
2393
+ return result.isValid && u8aEq2(vrfResult.subarray(0, 32), vrfHash(vrfResult.subarray(32), context, extra));
2394
+ }
2395
+ };
2396
+ }
2397
+
2398
+ // node_modules/.pnpm/@polkadot+keyring@13.5.9_@polkadot+util-crypto@13.5.9_@polkadot+util@13.5.9__@polkadot+util@13.5.9/node_modules/@polkadot/keyring/defaults.js
2399
+ var DEV_PHRASE = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
2400
+
2401
+ // node_modules/.pnpm/@polkadot+keyring@13.5.9_@polkadot+util-crypto@13.5.9_@polkadot+util@13.5.9__@polkadot+util@13.5.9/node_modules/@polkadot/keyring/pairs.js
2402
+ import { isHex, isU8a, u8aToHex as u8aToHex2, u8aToU8a as u8aToU8a2 } from "@polkadot/util";
2403
+ import { decodeAddress } from "@polkadot/util-crypto";
2404
+ var _map;
2405
+ var Pairs = class {
2406
+ constructor() {
2407
+ __privateAdd(this, _map, {});
2408
+ }
2409
+ add(pair) {
2410
+ __privateGet(this, _map)[decodeAddress(pair.address).toString()] = pair;
2411
+ return pair;
2412
+ }
2413
+ all() {
2414
+ return Object.values(__privateGet(this, _map));
2415
+ }
2416
+ get(address) {
2417
+ const pair = __privateGet(this, _map)[decodeAddress(address).toString()];
2418
+ if (!pair) {
2419
+ throw new Error(`Unable to retrieve keypair '${isU8a(address) || isHex(address) ? u8aToHex2(u8aToU8a2(address)) : address}'`);
2420
+ }
2421
+ return pair;
2422
+ }
2423
+ remove(address) {
2424
+ delete __privateGet(this, _map)[decodeAddress(address).toString()];
2425
+ }
2426
+ };
2427
+ _map = new WeakMap();
2428
+
2429
+ // node_modules/.pnpm/@polkadot+keyring@13.5.9_@polkadot+util-crypto@13.5.9_@polkadot+util@13.5.9__@polkadot+util@13.5.9/node_modules/@polkadot/keyring/keyring.js
2430
+ var PairFromSeed = {
2431
+ ecdsa: (seed) => secp256k1FromSeed2(seed),
2432
+ ed25519: (seed) => ed25519FromSeed2(seed),
2433
+ ethereum: (seed) => secp256k1FromSeed2(seed),
2434
+ sr25519: (seed) => sr25519FromSeed2(seed)
2435
+ };
2436
+ function pairToPublic({ publicKey }) {
2437
+ return publicKey;
2438
+ }
2439
+ var _pairs, _type, _ss58;
2440
+ var Keyring3 = class {
2441
+ constructor(options = {}) {
2442
+ __privateAdd(this, _pairs);
2443
+ __privateAdd(this, _type);
2444
+ __privateAdd(this, _ss58);
2445
+ __publicField(this, "decodeAddress", decodeAddress2);
2446
+ /**
2447
+ * @name encodeAddress
2448
+ * @description Encodes the input into an ss58 representation
2449
+ */
2450
+ __publicField(this, "encodeAddress", (address, ss58Format) => {
2451
+ return this.type === "ethereum" ? ethereumEncode2(address) : encodeAddress(address, ss58Format ?? __privateGet(this, _ss58));
2452
+ });
2453
+ options.type = options.type || "ed25519";
2454
+ if (!["ecdsa", "ethereum", "ed25519", "sr25519"].includes(options.type || "undefined")) {
2455
+ throw new Error(`Expected a keyring type of either 'ed25519', 'sr25519', 'ethereum' or 'ecdsa', found '${options.type || "unknown"}`);
2456
+ }
2457
+ __privateSet(this, _pairs, new Pairs());
2458
+ __privateSet(this, _ss58, options.ss58Format);
2459
+ __privateSet(this, _type, options.type);
2460
+ }
2461
+ /**
2462
+ * @description retrieve the pairs (alias for getPairs)
2463
+ */
2464
+ get pairs() {
2465
+ return this.getPairs();
2466
+ }
2467
+ /**
2468
+ * @description retrieve the publicKeys (alias for getPublicKeys)
2469
+ */
2470
+ get publicKeys() {
2471
+ return this.getPublicKeys();
2472
+ }
2473
+ /**
2474
+ * @description Returns the type of the keyring, ed25519, sr25519 or ecdsa
2475
+ */
2476
+ get type() {
2477
+ return __privateGet(this, _type);
2478
+ }
2479
+ /**
2480
+ * @name addPair
2481
+ * @summary Stores an account, given a keyring pair, as a Key/Value (public key, pair) in Keyring Pair Dictionary
2482
+ */
2483
+ addPair(pair) {
2484
+ return __privateGet(this, _pairs).add(pair);
2485
+ }
2486
+ /**
2487
+ * @name addFromAddress
2488
+ * @summary Stores an account, given an account address, as a Key/Value (public key, pair) in Keyring Pair Dictionary
2489
+ * @description Allows user to explicitly provide separate inputs including account address or public key, and optionally
2490
+ * the associated account metadata, and the default encoded value as arguments (that may be obtained from the json file
2491
+ * of an account backup), and then generates a keyring pair from them that it passes to
2492
+ * `addPair` to stores in a keyring pair dictionary the public key of the generated pair as a key and the pair as the associated value.
2493
+ */
2494
+ addFromAddress(address, meta = {}, encoded = null, type = this.type, ignoreChecksum, encType) {
2495
+ const publicKey = this.decodeAddress(address, ignoreChecksum);
2496
+ return this.addPair(createPair({ toSS58: this.encodeAddress, type }, { publicKey, secretKey: new Uint8Array() }, meta, encoded, encType));
2497
+ }
2498
+ /**
2499
+ * @name addFromJson
2500
+ * @summary Stores an account, given JSON data, as a Key/Value (public key, pair) in Keyring Pair Dictionary
2501
+ * @description Allows user to provide a json object argument that contains account information (that may be obtained from the json file
2502
+ * of an account backup), and then generates a keyring pair from it that it passes to
2503
+ * `addPair` to stores in a keyring pair dictionary the public key of the generated pair as a key and the pair as the associated value.
2504
+ */
2505
+ addFromJson(json, ignoreChecksum) {
2506
+ return this.addPair(this.createFromJson(json, ignoreChecksum));
2507
+ }
2508
+ /**
2509
+ * @name addFromMnemonic
2510
+ * @summary Stores an account, given a mnemonic, as a Key/Value (public key, pair) in Keyring Pair Dictionary
2511
+ * @description Allows user to provide a mnemonic (seed phrase that is provided when account is originally created)
2512
+ * argument and a metadata argument that contains account information (that may be obtained from the json file
2513
+ * of an account backup), and then generates a keyring pair from it that it passes to
2514
+ * `addPair` to stores in a keyring pair dictionary the public key of the generated pair as a key and the pair as the associated value.
2515
+ */
2516
+ addFromMnemonic(mnemonic, meta = {}, type = this.type, wordlist) {
2517
+ return this.addFromUri(mnemonic, meta, type, wordlist);
2518
+ }
2519
+ /**
2520
+ * @name addFromPair
2521
+ * @summary Stores an account created from an explicit publicKey/secreteKey combination
2522
+ */
2523
+ addFromPair(pair, meta = {}, type = this.type) {
2524
+ return this.addPair(this.createFromPair(pair, meta, type));
2525
+ }
2526
+ /**
2527
+ * @name addFromSeed
2528
+ * @summary Stores an account, given seed data, as a Key/Value (public key, pair) in Keyring Pair Dictionary
2529
+ * @description Stores in a keyring pair dictionary the public key of the pair as a key and the pair as the associated value.
2530
+ * Allows user to provide the account seed as an argument, and then generates a keyring pair from it that it passes to
2531
+ * `addPair` to store in a keyring pair dictionary the public key of the generated pair as a key and the pair as the associated value.
2532
+ */
2533
+ addFromSeed(seed, meta = {}, type = this.type) {
2534
+ return this.addPair(createPair({ toSS58: this.encodeAddress, type }, PairFromSeed[type](seed), meta, null));
2535
+ }
2536
+ /**
2537
+ * @name addFromUri
2538
+ * @summary Creates an account via an suri
2539
+ * @description Extracts the phrase, path and password from a SURI format for specifying secret keys `<secret>/<soft-key>//<hard-key>///<password>` (the `///password` may be omitted, and `/<soft-key>` and `//<hard-key>` maybe repeated and mixed). The secret can be a hex string, mnemonic phrase or a string (to be padded)
2540
+ */
2541
+ addFromUri(suri, meta = {}, type = this.type, wordlist) {
2542
+ return this.addPair(this.createFromUri(suri, meta, type, wordlist));
2543
+ }
2544
+ /**
2545
+ * @name createFromJson
2546
+ * @description Creates a pair from a JSON keyfile
2547
+ */
2548
+ createFromJson({ address, encoded, encoding: { content, type, version }, meta }, ignoreChecksum) {
2549
+ if (version === "3" && content[0] !== "pkcs8") {
2550
+ throw new Error(`Unable to decode non-pkcs8 type, [${content.join(",")}] found}`);
2551
+ }
2552
+ const cryptoType = version === "0" || !Array.isArray(content) ? this.type : content[1];
2553
+ const encType = !Array.isArray(type) ? [type] : type;
2554
+ if (!["ed25519", "sr25519", "ecdsa", "ethereum"].includes(cryptoType)) {
2555
+ throw new Error(`Unknown crypto type ${cryptoType}`);
2556
+ }
2557
+ const publicKey = isHex2(address) ? hexToU8a2(address) : this.decodeAddress(address, ignoreChecksum);
2558
+ const decoded = isHex2(encoded) ? hexToU8a2(encoded) : base64Decode(encoded);
2559
+ return createPair({ toSS58: this.encodeAddress, type: cryptoType }, { publicKey, secretKey: new Uint8Array() }, meta, decoded, encType);
2560
+ }
2561
+ /**
2562
+ * @name createFromPair
2563
+ * @summary Creates a pair from an explicit publicKey/secreteKey combination
2564
+ */
2565
+ createFromPair(pair, meta = {}, type = this.type) {
2566
+ return createPair({ toSS58: this.encodeAddress, type }, pair, meta, null);
2567
+ }
2568
+ /**
2569
+ * @name createFromUri
2570
+ * @summary Creates a Keypair from an suri
2571
+ * @description This creates a pair from the suri, but does not add it to the keyring
2572
+ */
2573
+ createFromUri(_suri, meta = {}, type = this.type, wordlist) {
2574
+ const suri = _suri.startsWith("//") ? `${DEV_PHRASE}${_suri}` : _suri;
2575
+ const { derivePath, password, path: path2, phrase } = keyExtractSuri(suri);
2576
+ let seed;
2577
+ const isPhraseHex = isHex2(phrase, 256);
2578
+ if (isPhraseHex) {
2579
+ seed = hexToU8a2(phrase);
2580
+ } else {
2581
+ const parts = phrase.split(" ");
2582
+ if ([12, 15, 18, 21, 24].includes(parts.length)) {
2583
+ seed = type === "ethereum" ? mnemonicToLegacySeed(phrase, "", false, 64) : mnemonicToMiniSecret(phrase, password, wordlist);
2584
+ } else {
2585
+ if (phrase.length > 32) {
2586
+ throw new Error("specified phrase is not a valid mnemonic and is invalid as a raw seed at > 32 bytes");
2587
+ }
2588
+ seed = stringToU8a(phrase.padEnd(32));
2589
+ }
2590
+ }
2591
+ const derived = type === "ethereum" ? isPhraseHex ? PairFromSeed[type](seed) : hdEthereum(seed, derivePath.substring(1)) : keyFromPath2(PairFromSeed[type](seed), path2, type);
2592
+ return createPair({ toSS58: this.encodeAddress, type }, derived, meta, null);
2593
+ }
2594
+ /**
2595
+ * @name getPair
2596
+ * @summary Retrieves an account keyring pair from the Keyring Pair Dictionary, given an account address
2597
+ * @description Returns a keyring pair value from the keyring pair dictionary by performing
2598
+ * a key lookup using the provided account address or public key (after decoding it).
2599
+ */
2600
+ getPair(address) {
2601
+ return __privateGet(this, _pairs).get(address);
2602
+ }
2603
+ /**
2604
+ * @name getPairs
2605
+ * @summary Retrieves all account keyring pairs from the Keyring Pair Dictionary
2606
+ * @description Returns an array list of all the keyring pair values that are stored in the keyring pair dictionary.
2607
+ */
2608
+ getPairs() {
2609
+ return __privateGet(this, _pairs).all();
2610
+ }
2611
+ /**
2612
+ * @name getPublicKeys
2613
+ * @summary Retrieves Public Keys of all Keyring Pairs stored in the Keyring Pair Dictionary
2614
+ * @description Returns an array list of all the public keys associated with each of the keyring pair values that are stored in the keyring pair dictionary.
2615
+ */
2616
+ getPublicKeys() {
2617
+ return __privateGet(this, _pairs).all().map(pairToPublic);
2618
+ }
2619
+ /**
2620
+ * @name removePair
2621
+ * @description Deletes the provided input address or public key from the stored Keyring Pair Dictionary.
2622
+ */
2623
+ removePair(address) {
2624
+ __privateGet(this, _pairs).remove(address);
2625
+ }
2626
+ /**
2627
+ * @name setSS58Format;
2628
+ * @description Sets the ss58 format for the keyring
2629
+ */
2630
+ setSS58Format(ss58) {
2631
+ __privateSet(this, _ss58, ss58);
2632
+ }
2633
+ /**
2634
+ * @name toJson
2635
+ * @summary Returns a JSON object associated with the input argument that contains metadata assocated with an account
2636
+ * @description Returns a JSON object containing the metadata associated with an account
2637
+ * when valid address or public key and when the account passphrase is provided if the account secret
2638
+ * is not already unlocked and available in memory. Note that in [Polkadot-JS Apps](https://github.com/polkadot-js/apps) the user
2639
+ * may backup their account to a JSON file that contains this information.
2640
+ */
2641
+ toJson(address, passphrase) {
2642
+ return __privateGet(this, _pairs).get(address).toJson(passphrase);
2643
+ }
2644
+ };
2645
+ _pairs = new WeakMap();
2646
+ _type = new WeakMap();
2647
+ _ss58 = new WeakMap();
2118
2648
  export {
2119
2649
  API_EXTENSIONS,
2120
2650
  API_RPC,
@@ -2127,6 +2657,7 @@ export {
2127
2657
  DEFAULT_EMPTY_PAYLOAD,
2128
2658
  FileFromMetadataRef,
2129
2659
  HttpProvider,
2660
+ Keyring3 as Keyring,
2130
2661
  MCryptFs,
2131
2662
  MCryptFsReader,
2132
2663
  MCryptFsWriter,
@@ -2138,6 +2669,7 @@ export {
2138
2669
  WsProvider3 as WsProvider,
2139
2670
  addStake,
2140
2671
  base64ToUint8Array,
2672
+ buildFee,
2141
2673
  clearTokenCache,
2142
2674
  configure,
2143
2675
  createAccount,